ftimme
2012-09-14 aea33775732e79e029d2d96816b565db61ca419d
interface/lib/classes/client_templates.inc.php
@@ -9,15 +9,13 @@
 
class client_templates {
   function apply_client_templates($clientId, $limits = array()) {
   function apply_client_templates($clientId) {
        global $app;
        if(!is_array($limits)) $limits = array();
        
        /*
         * Get the master-template for the client
         */
        $sql = "SELECT template_master, template_additional FROM client WHERE client_id = " . intval($clientId);
        $sql = "SELECT template_master, template_additional FROM client WHERE client_id = " . $app->functions->intval($clientId);
        $record = $app->db->queryOneRecord($sql);
        $masterTemplateId = $record['template_master'];
        $additionalTemplateStr = $record['template_additional'];
@@ -26,8 +24,13 @@
         * if the master-Template is custom there is NO changing
         */
        if ($masterTemplateId > 0){
            $sql = "SELECT * FROM client_template WHERE template_id = " . intval($masterTemplateId);
            $sql = "SELECT * FROM client_template WHERE template_id = " . $app->functions->intval($masterTemplateId);
            $limits = $app->db->queryOneRecord($sql);
        } else {
            // if there is no master template it makes NO SENSE adding sub templates.
            // adding subtemplates are stored in client limits, so they would add up
            // on every save action for the client -> too high limits!
            return;
        }
        /*
@@ -37,7 +40,7 @@
        $addTpl = explode('/', $additionalTemplateStr);
        foreach ($addTpl as $item){
            if (trim($item) != ''){
                $sql = "SELECT * FROM client_template WHERE template_id = " . intval($item);
                $sql = "SELECT * FROM client_template WHERE template_id = " . $app->functions->intval($item);
                $addLimits = $app->db->queryOneRecord($sql);
                /* maybe the template is deleted in the meantime */
                if (is_array($addLimits)){
@@ -112,7 +115,7 @@
            }
        }
        if($update != '') {
            $sql = 'UPDATE client SET ' . $update . " WHERE client_id = " . intval($clientId);
            $sql = 'UPDATE client SET ' . $update . " WHERE client_id = " . $app->functions->intval($clientId);
            $app->db->query($sql);
        }
    }