/** * Save profile tool list action value */ public function save() { $this->toolActionList; // delete all relation $sql = "DELETE FROM `" . $this->tbl['rel_profile_action'] . "`\n WHERE profile_id=" . $this->profile->id . "\n AND courseId = '' "; claro_sql_query($sql); // insert new relation foreach ($this->toolActionList as $toolId => $actionList) { foreach ($actionList as $actionName => $actionValue) { if ($actionValue == true) { $actionValue = 1; } else { $actionValue = 0; } $action = new RightToolAction(); $action->load($actionName, $toolId); $actionId = $action->getId(); $sql = "INSERT INTO `" . $this->tbl['rel_profile_action'] . "`\n SET profile_id = " . $this->profile->id . ",\n action_id = " . $actionId . ",\n value = " . $actionValue . ",\n courseId = '' "; claro_sql_query($sql); } } }
/** * Save profile tool list action value */ public function save() { // delete all relation $sql = "DELETE FROM `" . $this->tbl['rel_profile_action'] . "`\n WHERE profile_id=" . $this->profile->id . "\n AND courseId = '" . claro_sql_escape($this->courseId) . "'"; claro_sql_query($sql); // insert new relation foreach ($this->toolActionList as $toolId => $actionList) { // get difference between default and course $toolActionListDiff = array_diff_assoc($this->defaultToolActionList[$toolId], $actionList); if (!empty($toolActionListDiff)) { foreach ($actionList as $actionName => $actionValue) { if ($actionValue == true) { $actionValue = 1; } else { $actionValue = 0; } $action = new RightToolAction(); $action->load($actionName, $toolId); $actionId = $action->getId(); $sql = "INSERT INTO `" . $this->tbl['rel_profile_action'] . "`\n SET profile_id = " . $this->profile->id . ",\n action_id = " . $actionId . ",\n value = " . $actionValue . ",\n courseId = '" . claro_sql_escape($this->courseId) . "'"; claro_sql_query($sql); } } } }