Marius Cramer
2015-04-07 cc7a82756b4f4d7ab18e928527c37489adbaf564
interface/web/client/reseller_edit.php
@@ -61,11 +61,11 @@
         // Get the limits of the client
         $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
         $client = $app->db->queryOneRecord("SELECT limit_client FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
         $client = $app->db->queryOneRecord("SELECT limit_client FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id);
         // Check if the user may add another website.
         if($client["limit_client"] >= 0) {
            $tmp = $app->db->queryOneRecord("SELECT count(client_id) as number FROM client WHERE sys_groupid = $client_group_id");
            $tmp = $app->db->queryOneRecord("SELECT count(client_id) as number FROM client WHERE sys_groupid = ?", $client_group_id);
            if($tmp["number"] >= $client["limit_client"]) {
               $app->error($app->tform->wordbook["limit_client_txt"]);
            }
@@ -84,11 +84,11 @@
         // Get the limits of the client
         $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
         $client = $app->db->queryOneRecord("SELECT limit_client FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
         $client = $app->db->queryOneRecord("SELECT limit_client FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id);
         // Check if the user may add another website.
         if($client["limit_client"] >= 0) {
            $tmp = $app->db->queryOneRecord("SELECT count(client_id) as number FROM client WHERE sys_groupid = $client_group_id");
            $tmp = $app->db->queryOneRecord("SELECT count(client_id) as number FROM client WHERE sys_groupid = ?", $client_group_id);
            if($tmp["number"] >= $client["limit_client"]) {
               $app->error($app->tform->wordbook["limit_client_txt"]);
            }
@@ -266,6 +266,47 @@
            
         }
      }
      //* Send welcome email
      $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
      $sql = "SELECT * FROM client_message_template WHERE template_type = 'welcome' AND sys_groupid = ".$client_group_id;
      $email_template = $app->db->queryOneRecord($sql);
      $client = $app->tform->getDataRecord($this->id);
      if(is_array($email_template) && $client['email'] != '') {
         //* Parse client details into message
         $message = $email_template['message'];
         $subject = $email_template['subject'];
         foreach($client as $key => $val) {
            switch ($key) {
            case 'password':
               $message = str_replace('{password}', $this->dataRecord['password'], $message);
               $subject = str_replace('{password}', $this->dataRecord['password'], $subject);
               break;
            case 'gender':
               $message = str_replace('{salutation}', $wb['gender_'.$val.'_txt'], $message);
               $subject = str_replace('{salutation}', $wb['gender_'.$val.'_txt'], $subject);
               break;
            default:
               $message = str_replace('{'.$key.'}', $val, $message);
               $subject = str_replace('{'.$key.'}', $val, $subject);
            }
         }
         //* Get sender address
         if($app->auth->is_admin()) {
            $app->uses('getconf');
            $system_config = $app->getconf->get_global_config();
            $from = $system_config['admin_mail'];
         } else {
            $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
            $reseller = $app->db->queryOneRecord("SELECT client.email FROM sys_group,client WHERE client.client_id = sys_group.client_id and sys_group.groupid = ".$client_group_id);
            $from = $reseller["email"];
         }
         //* Send the email
         $app->functions->mail($client['email'], $subject, $message, $from);
      }
      parent::onAfterInsert();
   }