Jump to content

carux

New Member
  • Posts

    2
  • Joined

  • Last visited

About carux

carux's Achievements

Junior Member

Junior Member (1/3)

0

Reputation

  1. HI, i've created my own addon module but i encountered an issue. When i submit the form generated, I am automatically redirected to the clientarea.php section without the function defined in the form action being executed. <?php require __DIR__ . '/vendor/autoload.php'; use WHMCS\Database\Capsule as DB; use \Ovh\Api; add_hook('ClientAreaAction',1,function($action,$vars){ if ($action == 'updateUsage'){ print_r($vars); return ; } }) add_hook('ClientAreaProductDetailsOutput',1, function($service) { try{ $domain = $service['service']['domain']; /**custom style*/ $style = getCustomStyle(); $content = getAccountByDomain($domain); $js = '<script src="/modules/addons/ovhmail/js/password.js"></script>'; return $style.$content.$js; }catch (Exception $th){} }); function getAccountByDomain($domain){ /**get config variables -> applicationKey, applicationSecret, endpoint, consumerKey*/ $config_variables = getConfigVariables(); /**set api key*/ $applicationKey = $config_variables['applicationKey']; $applicationSecret = $config_variables['applicationSecret']; $endpoint = $config_variables['endpoint']; $consumerKey = $config_variables['consumerKey']; /**set object Api*/ $ovh = new Api($applicationKey, $applicationSecret, $endpoint, $consumerKey); /**get all account linked to $domain*/ $result = $ovh->get('/email/domain/'.$domain.'/account'); /**order in alphabetical order*/ asort($result); /**array for usage quota and updateDate*/ $result_usage = []; $result_date = []; foreach ($result as $account){ $result_usageQuota = $ovh->get('/email/domain/'.$domain.'/account/'.$account.'/usage'); $result_usage[$account] = $result_usageQuota['quota']; $result_date[$account] = $result_usageQuota['date'] ? date('d/m/Y H:i:s' , strtotime($result_usageQuota['date'])) : ''; } return getFormManageMailbox($domain , $result , $result_usage , $result_date); } /**get config variables set when activated module*/ function getConfigVariables(){ $setting = DB::table('tbladdonmodules')->select('*')->where('module', 'ovhmail')->get(); $setting = json_decode($setting); $config_variables = []; foreach ($setting as $item) { if ($item->setting != 'access' && $item->setting != 'version') $config_variables[$item->setting] = $item->value; } return ($config_variables); } /**get custom style for element in getFormManageMailbox*/ function getCustomStyle(){ return ' <style> table tr>*{ padding: 5px; } .password-strength-bar { width: 100%; height: 10px; background-color: #ccc; } .strength { width: 0; height: 100%; transition: width 0.3s; } </style>'; } /**get form to set new password for account*/ function getFormManageMailbox($domain , $result , $result_usage , $result_date){ $html = '<div id="container-form-manage-mailbox"> <div class="header-lined"> <h1>Gestione caselle per il dominio '.$domain.' </div> <div class="update-usage-mailbox-form"> <form method="post" action="clientarea.php?action=updateUsage"> <h3>Aggiorna lo spazio utilizzato dalle caselle nel tuo dominio</h3> <button type="submit">Aggiorna</button> </form> </div> <div class="set-new-password-mailbox"> <table> <thead align="left" style="display: table-header-group"> <tr> <th>Casella email </th> <th>Spazio utilizzato</th> <th>Ultimo aggiornamento</th> <th>Scegli Password </th> <th>Ripeti Password</th> <th></th> </tr> </thead> <tbody>'; /**print mailbox row by row*/ $i = 1; foreach ($result as $email){ $html .= ' <tr> <form method="post" action=""> <td><input type="hidden" name="account" value="'.$email.'">'.$email.'@'.$domain.'</td> <td>'.$result_quota[$email].'</td> <td>'.$result_date[$email].'</td> <td> <input type="password" name="new_password" id="password-'.$i.'"/> <div class="password-strength-bar" id="password-strength-bar-'.$i.'"> <div class="strength" id="strength-'.$i.'"></div> </div> </td> <td> <input type="password" name="repeat"/> <div style="display:none" id="password-match-message-'.$i.'">Le password non coincidono.</div> </td> <td><button type="submit" id="change-password-'.$i.'" style="display:none">Cambia password</button></td> </form> </tr>'; $i++; } /**path to js function*/ $html .= ' </tbody> </table> </div> <div class="make-new-mailbox"> <h2>Crea una nuova casella per il dominio '.$domain.'</h2> <table> <thead> <tr> <th>Nome account (non inserire @dominio)</th> <th>Descrizione</th> <th>Password</th> <th>Spazio da utilizzare</th> <th></th> </tr> </thead> <tbody> <tr> <form method="post" action=""> <td><input type="text" class="new_mailbox" name="new_account"></td> <td><textarea class="new_mailbox" name="description_new_mailbox"></textarea></td> <td> <input type="password" class="new_mailbox" name="new_password" id="password-'.$i.'"/> <div class="password-strength-bar" id="password-strength-bar-'.$i.'"> <div class="strength" id="strength-'.$i.'"></div> </div> </td> <td><input type="number" class="new_mailbox" name="usage_quota_new_mailbox" value="5000000000"></td> <td><button type="submit" id="new_mailbox_btn" style="display:none">Crea casella</button></td> </form> </tr> </tbody> </table> </div> '; $html .= '</div>'; return $html; } ?> Thank you soo much for helping.
  2. Hi everyone, I've built my custom addon module that has this division into folder : module_name.php hooks.php templates - template_name.tpl . I would add template_name.tpl in product details page after the main-content section. Someone can help me? Thanks in advance.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated