function add_row($row, $pk) { foreach ($pk as $key => $val) { $pk[$key] = addslashes(trim($val)); } foreach ($row as $key => $val) { $row[$key] = addslashes(trim($val)); } $user = $this->aclm->getUser(false, $pk['username']); if ($user != false) { // admin type and profile ? switch ($row['admin_type']) { case 'admin': $level = $this->levels[ADMIN_GROUP_ADMIN]; if (!isset($this->admin_profiles[$row['profile']])) { $this->last_error = 'Profile not found : ' . $row['profile'] . '<br />'; return false; } $this->db->start_transaction(); //remove from the user group $this->aclm->removeFromGroup($this->levels[ADMIN_GROUP_USER], $user[ACL_INFO_IDST]); //add to the correct admin group $this->aclm->addToGroup($level, $user[ACL_INFO_IDST]); $idst_profile = $this->admin_profiles[$row['profile']]; $this->m_ar->saveSingleAdminAssociation($idst_profile, $user[ACL_INFO_IDST]); break; case 'public': $level = $this->levels[ADMIN_GROUP_PUBLICADMIN]; if (!isset($this->public_profiles[$row['profile']])) { $this->last_error = 'Profile not found : ' . $row['profile'] . '<br />'; return false; } $this->db->start_transaction(); //remove from the user group $this->aclm->removeFromGroup($this->levels[ADMIN_GROUP_USER], $user[ACL_INFO_IDST]); //add to the correct admin group $this->aclm->addToGroup($level, $user[ACL_INFO_IDST]); $idst_profile = $this->public_profiles[$row['profile']]; $this->m_ap->saveSingleAdminAssociation($idst_profile, $user[ACL_INFO_IDST]); break; } // associated org_chart ? if ($row['folder_name'] == 'root' && isset($this->root_ocd)) { $this->preference->saveAdminTree($user[ACL_INFO_IDST], array($this->root_ocd)); } elseif (isset($this->org_chart[strtolower($row['folder_name'])])) { $oc = $this->org_chart[strtolower($row['folder_name'])]; $this->preference->saveAdminTree($user[ACL_INFO_IDST], array($oc->idst_ocd)); } else { $this->last_error = 'Users to manage not found <br />'; } // associated courses ? if ($row['courses'] == 'root') { $this->preference->saveAdminCourse($user[ACL_INFO_IDST], array(0), array(), array()); } else { $this->last_error = 'Course association not found <br />'; } $this->db->commit(); return true; } else { $this->last_error = 'User not found : ' . $pk['username'] . '<br />'; return false; } }