/** * Constructor. * Loads all Id variables if * * @param integer $id of profile in DB * @return void * @access public */ function __construct($id = false) { $this->_users = array(); if ($id) { if (!SensitiveIO::isPositiveInteger($id)) { $this->raiseError('Id is not a positive integer'); return; } $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tprofilesUsersGroups,\n\t\t\t\t\tprofiles\n\t\t\t\twhere\n\t\t\t\t\tid_prg='" . $id . "' and\n\t\t\t\t\tid_pr=profile_prg\n\t\t\t"; $q = new CMS_query($sql); if ($q->getNumRows()) { $data = $q->getArray(); $this->_groupId = $id; $this->_label = $data["label_prg"]; $this->_description = $data["description_prg"]; parent::__construct($data); // Create users array $sql = "\n\t\t\t\t\tselect\n\t\t\t\t\t\tuserId_gu\n\t\t\t\t\tfrom\n\t\t\t\t\t\tprofileUsersByGroup,\n\t\t\t\t\t\tprofilesUsers\n\t\t\t\t\twhere\n\t\t\t\t\t\tgroupId_gu='" . $id . "'\n\t\t\t\t\t\tand userId_gu = id_pru\n\t\t\t\t\t\tand deleted_pru = 0\n\t\t\t\t"; $q = new CMS_query($sql); if ($q->getNumRows()) { while ($userId = $q->getValue("userId_gu")) { $this->_users[] = $userId; } } $this->_usersOld = $this->_users; } else { $this->raiseError('Unknown DB ID : ' . $id); } } else { // initialize super class object and users parent::__construct(); } }
/** * Constructor. * Loads all Id variables if * * @param integer $id id of profile in DB * @return void * @access public */ function __construct($id = false) { // Initiate Stack objects $this->_alerts = new CMS_stack(); if ($id) { if (!SensitiveIO::isPositiveInteger($id)) { $this->raiseError("Id is not a positive integer"); return; } $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tprofilesUsers,\n\t\t\t\t\tcontactDatas,\n\t\t\t\t\tprofiles\n\t\t\t\twhere\n\t\t\t\t\tid_pru='{$id}' and\n\t\t\t\t\tid_cd=contactData_pru and\n\t\t\t\t\tid_pr=profile_pru\n\t\t\t"; $q = new CMS_query($sql); if ($q->getNumRows()) { $data = $q->getArray(); } else { $this->raiseError("Unknown DB ID : " . $id); $this->_language = new CMS_language(); $this->_contactData = CMS_contactDatas_catalog::getByUser(array()); // Initialize super class parent::__construct(); } if (isset($data) && is_array($data)) { $this->_userId = $id; $this->_login = $data["login_pru"]; $this->_password = $data["password_pru"]; $this->_firstName = $data["firstName_pru"]; $this->_lastName = $data["lastName_pru"]; parent::__construct($data); $this->_language = CMS_languagesCatalog::getByCode($data["language_pru"]); $this->_active = $data["active_pru"]; $this->_deleted = $data["deleted_pru"]; $this->_favorites = $data["favorites_pru"] ? explode(',', $data["favorites_pru"]) : array(); $this->_alerts->setTextDefinition($data["alerts_pru"]); $this->_contactData = CMS_contactDatas_catalog::getByUser($data); } } else { $this->_language = new CMS_language(); $this->_contactData = CMS_contactDatas_catalog::getByUser(array()); // Initialize super class parent::__construct(); } }