public function update(Profile $O_profile) { if (!is_null($O_profile->getId())) { if (!$O_profile->getName() || !$O_profile->getSlug() || !$O_profile->getLevel()) { throw new Exception("Des informations obligatoires sont manquantes, nous ne pouvons pas mettre à jour le profile"); } $I_id = $O_profile->getId(); $S_name = $O_profile->getName(); $S_sql = 'UPDATE profile SET name = ? WHERE id = ?'; $A_params = array($S_name, $I_id); $O_connection = new Connection(); if ($A_data = $O_connection->requestDb($S_sql, $A_params)) { return true; } } return false; }
public function builder() { //the profile id passed in the URL if (isset($_GET['profileId'])) { $id = $_GET['profileId']; } else { $id = 0; } //get the profile from the config db $query = $this->configDb->prepare("SELECT * FROM profiles WHERE id = :id LIMIT 1"); $query->bindValue(':id', $id); $query->execute(); $profileData = $query->fetchAll(); //make sure a profile was found if (count($profileData) == 0) { $this->viewModel->set("success", false); $this->viewModel->set("message", "Error - the profile id was either missing from the URL or it is invalid."); return $this->viewModel; } //profile was found so create an instance of the profile object require "classes\\profile.php"; $profile = new Profile($profileData[0], null); //get the counters $this->perfmonSQL->setDetails($profile->getDbODBC(), $profile->getDbUser(), $profile->getDbPassword()); if ($this->perfmonSQL->connect()) { $query = $this->perfmonSQL->db->prepare("SELECT DISTINCT HASHBYTES('MD5', ObjectName + CounterName + ISNULL(InstanceName,'')) AS CounterId,ObjectName,CounterName,InstanceName FROM dbo.CounterDetails ORDER BY CounterName ASC"); $query->execute(); $counters = $query->fetchAll(); if (count($counters) > 0) { $this->viewModel->set("counters", $counters); } else { $this->viewModel->set("success", false); $this->viewModel->set("message", "Error - the perfmon DB for this profile does not currently have any counters."); return $this->viewModel; } } else { $this->viewModel->set("success", false); $this->viewModel->set("message", $this->perfmonSQL->getMessage()); return $this->viewModel; } $this->viewModel->set("success", true); $this->viewModel->set("profileName", $profile->getProfileName()); $this->viewModel->set("profileId", $profile->getId()); return $this->viewModel; }
public function machines() { //the profile id passed in the URL if (isset($_GET['profileId'])) { $id = $_GET['profileId']; } else { $id = 0; } //get the profile from the config db $query = $this->configDb->prepare("SELECT * FROM profiles WHERE id = :id LIMIT 1"); $query->bindValue(':id', $id); $query->execute(); $profileData = $query->fetchAll(); //make sure a profile was found if (count($profileData) == 0) { $this->viewModel->set("success", false); $this->viewModel->set("message", "Error - the profile id was either missing from the URL or it is invalid."); return $this->viewModel; } //profile was found so create an instance of the profile object require "classes\\profile.php"; $profile = new Profile($profileData[0], null); //get the machine names $this->perfmonSQL->setDetails($profile->getDbODBC(), $profile->getDbUser(), $profile->getDbPassword()); if ($this->perfmonSQL->connect()) { $query = $this->perfmonSQL->db->prepare("SELECT DISTINCT RIGHT(CounterDetails.MachineName, LEN(CounterDetails.MachineName) - 2) AS MachineName FROM dbo.CounterDetails"); $query->execute(); $clients = $query->fetchAll(); $this->viewModel->set("clients", $clients); $this->viewModel->set("clientCount", count($clients)); } else { $this->viewModel->set("success", false); $this->viewModel->set("message", $this->perfmonSQL->getMessage()); return $this->viewModel; } $this->viewModel->set("success", true); $this->viewModel->set("profileName", $profile->getProfileName()); $this->viewModel->set("profileId", $profile->getId()); return $this->viewModel; }
/** * Delete modal for the profile * Checks if the delete is permitted * @author Abhik Chakraborty */ include_once "config.php"; $sqrecord = (int) $_GET["sqrecord"]; $obj = $_GET["classname"]; $module = $_GET["m"]; $return_page = $_GET["referrar"]; $allow_del = false; if ((int) $sqrecord == 0) { $msg = _('You are trying to delete a report which does not exist !'); } else { $do_profile = new Profile(); $do_profile->getId($sqrecord); if ($do_profile->getNumRows() > 0) { $allow_del = true; $associated_roles = $do_profile->get_roles_attached_to_profile($sqrecord); } else { $msg = _('The profile you are trying to delete does not exist!'); } } if ($allow_del === true) { $e_del = new Event($obj . "->eventDeleteRecord"); $e_del->addParam("id", $sqrecord); if ($associated_roles === false) { $e_del->addParam("profile_transfer", "no"); } else { $e_del->addParam("profile_transfer", "yes"); }
<?php // Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt /** * Profile listing page * @author Abhik Chakraborty */ $do_profile = new Profile(); $do_profile->getId((int) $_GET["sqrecord"]); $do_module = new Module(); $do_module->get_all_active_module(); ?> <div class="container-fluid"> <div class="row"> <?php include_once "modules/Settings/settings_leftmenu.php"; ?> <div class="col-md-9"> <div class="box_content"> <ol class="breadcrumb"> <li class="active"><?php echo _('Settings'); ?> </li> <li><a href="<?php echo NavigationControl::getNavigationLink($module, "profile_list"); ?> "><?php echo _('Profile'); ?> </a></li>
/** Remove profile template from this user */ public function removeProfile(Profile $profile) { $db = AbstractDb::getObject(); $profile_id = $db->escapeString($profile->getId()); $sql = "DELETE FROM user_has_profiles WHERE user_id='{$this->id}' AND profile_id='{$profile_id}'"; return $db->execSqlUpdate($sql, false); }
/** * Exclude object from result * * @param Profile $profile Object to remove from the list of results * * @return ProfileQuery The current query, for fluid interface */ public function prune($profile = null) { if ($profile) { $this->addUsingAlias(ProfilePeer::ID, $profile->getId(), Criteria::NOT_EQUAL); } return $this; }
?> </a></h3> <p><?php echo _('Delete Profile'); ?> </p> </div> <div class="row-fluid"> <div id="rd_js_errors" style="display:none;"></div> <div class="datadisplay-outer"> <?php $do_role = new Roles(); if ($idprofile == 1) { $msg = _('The profile you are trying to delete is not allowd !'); } else { $do_profile->getId($idprofile); if ($do_profile->getNumRows() > 0) { $allow_role_delete = true; } else { $msg = _('The profile you are trying to delete does not exist !'); } } if ($allow_role_delete === false) { echo '<div class="alert alert-error alert-block" style="height:100px;margin-top:20px;margin-left:200px;margin-right:200px;">'; echo '<h4>'; echo _('Delete not allowed !'); echo '</h4>'; echo $msg; echo '</div>'; } elseif ($allow_role_delete === true) { $associated_roles = $do_role_profile_rel->get_roles_related_to_profile($idprofile);
/** * Create a new ProfileField in the database * * @param string $profile MANDATORY The profile this field belongs to * @param string $templateField MANDATORY The template this field is based on * @param string $id Optionnal The id to be given to the new Object. If * null, a new id will be assigned * * @return object The newly created object, or null if there was an * error (an exception is also trown) */ public static function createNewObject(Profile $profile = null, ProfileTemplateField $templateField = null, $id = null) { $db = AbstractDb::getObject(); $profileId = $db->escapeString($profile->getId()); $templateFieldId = $db->escapeString($templateField->getId()); if (empty($id)) { $fieldId = get_guid(); } else { $fieldId = $db->escapeString($id); } $sql = "INSERT INTO profile_fields (profile_id, profile_field_id, profile_template_field_id) VALUES ('{$profileId}', '{$fieldId}', '{$templateFieldId}');\n"; if (!$db->execSqlUpdate($sql, false)) { throw new Exception(_('Unable to insert the new profile fields in the database!')); } return self::getObject($fieldId); }
/** * Crear el usuario admin de sysPass. * Esta función crea el grupo, perfil y usuario 'admin' para utilizar sysPass. * * @throws SPException */ private static function createAdminAccount() { // Datos del grupo Groups::$groupName = "Admins"; Groups::$groupDescription = "Admins"; if (!Groups::addGroup()) { self::rollback(); throw new SPException(SPException::SP_CRITICAL, _('Error al crear el grupo "admin"'), _('Informe al desarrollador')); } $User = new User(); // Establecer el id de grupo del usuario al recién creado $User->setUserGroupId(Groups::$queryLastId); $Profile = new Profile(); $Profile->setName('Admin'); $Profile->setAccAdd(true); $Profile->setAccView(true); $Profile->setAccViewPass(true); $Profile->setAccViewHistory(true); $Profile->setAccEdit(true); $Profile->setAccEditPass(true); $Profile->setAccDelete(true); $Profile->setConfigGeneral(true); $Profile->setConfigEncryption(true); $Profile->setConfigBackup(true); $Profile->setMgmCategories(true); $Profile->setMgmCustomers(true); $Profile->setMgmUsers(true); $Profile->setMgmGroups(true); $Profile->setMgmProfiles(true); $Profile->setEvl(true); if (!$Profile->profileAdd()) { self::rollback(); throw new SPException(SPException::SP_CRITICAL, _('Error al crear el perfil "admin"'), _('Informe al desarrollador')); } // Datos del usuario $User->setUserLogin(self::$_username); $User->setUserPass(self::$_password); $User->setUserName('Admin'); $User->setUserProfileId($Profile->getId()); $User->setUserIsAdminApp(true); $User->setUserIsAdminAcc(false); $User->setUserIsDisabled(false); if (!$User->addUser()) { self::rollback(); throw new SPException(SPException::SP_CRITICAL, _('Error al crear el usuario "admin"'), _('Informe al desarrollador')); } // Guardar el hash de la clave maestra ConfigDB::setCacheConfigValue('masterPwd', Crypt::mkHashPassword(self::$_masterPassword)); ConfigDB::setCacheConfigValue('lastupdatempass', time()); ConfigDB::writeConfig(true); if (!$User->updateUserMPass(self::$_masterPassword)) { self::rollback(); throw new SPException(SPException::SP_CRITICAL, _('Error al actualizar la clave maestra del usuario "admin"'), _('Informe al desarrollador')); } }
/** * Declares an association between this object and a Profile object. * * @param Profile $v * @return void * @throws PropelException */ public function setProfile($v) { if ($v === null) { $this->setProfileId(NULL); } else { $this->setProfileId($v->getId()); } $this->aProfile = $v; }
/** * Function to check the permission related to the setting module data * @param string $current_file * @param integer $sqrecord * @return boolean */ public function action_permitted_settings($current_file, $sqrecord = '') { $retval = true; if (preg_match("#^group(.*)\$#i", $current_file) == 1 && (int) $sqrecord > 0) { $do_check = new Group(); $do_check->getId((int) $sqrecord); if ($do_check->getNumRows() == 0) { $retval = false; } $do_check->free(); } if (preg_match("#^profile(.*)\$#i", $current_file) == 1 && (int) $sqrecord > 0) { $do_check = new Profile(); $do_check->getId((int) $sqrecord); if ($do_check->getNumRows() == 0) { $retval = false; } else { if ($do_check->editable == 0 && ($current_file == 'profile_permissions' || $current_file == 'profile_details')) { $retval = false; } } $do_check->free(); } if (preg_match("#^roles(.*)\$#i", $current_file) == 1) { $idrole = ''; if ($_GET["parentrole"] != '') { $idrole = $_GET["parentrole"]; } elseif ($_GET["idrole"] != '') { $idrole = $_GET["idrole"]; } if ($idrole != '') { $do_check = new Roles(); $qry = "select * from `role` where idrole = :idrole"; $stmt = $do_check->getDbConnection()->prepare($qry); $stmt->bindValue(":idrole", $idrole); $stmt->execute(); if ($stmt->rowCount() == 0) { $retval = false; } else { $row = $stmt->fetch(); if ($row["editable"] == 0 && ($current_file == 'roles_edit' || $current_file == 'roles_detail')) { $retval = false; } } $do_check->free(); } } return $retval; }
public function update($id) { try { $this->db = fORMDatabase::retrieve(); $this->db->query('BEGIN'); $profile = new Profile($id); if (UserHelper::getProfileId() != $profile->getId() and !UserHelper::isEditor()) { throw new fValidationException('not allowed'); } $profile->setStartYear(fRequest::get('start_year')); $profile->setClassNumber(fRequest::get('class_number')); $profile->setStudentNumber(trim(fRequest::get('student_number'))); $profile->setBirthday(trim(fRequest::get('birthday'))); $profile->setGender(fRequest::get('gender')); //$profile->setLocation(trim(fRequest::get('location'))); $province = trim(fRequest::get('province')); $city = trim(fRequest::get('city')); $profile->setLocation(self::formatLocation($province, $city)); $profile->setPostNumber(trim(fRequest::get('post_number'))); $profile->setPrivacyControl(trim(fRequest::get('privacy', 'int', 0))); $profile->setField(trim(fRequest::get('field'))); $profile->setInstitute(trim(fRequest::get('institute'))); $profile->setPosition(trim(fRequest::get('position'))); $profile->setMajor(trim(fRequest::get('major'))); $profile->setMentor(trim(fRequest::get('mentor'))); $profile->setSubscription(trim(fRequest::get('subscription'))); $profile->store(); foreach ($profile->getContacts() as $contact) { $contact->delete(); } foreach ($this->contact_types as $type) { if (strlen(trim(fRequest::get($type)))) { $contact = new Contact(); $contact->setProfileId($profile->getId()); $contact->setType($type); $contact->setContent(trim(fRequest::get($type))); $contact->setCreatedAt(Util::currentTime()); $contact->store(); } } $this->db->query('COMMIT'); Activity::fireUpdateProfile(); $this->ajaxReturn(array('result' => 'success', 'profile_id' => $profile->getId())); } catch (fException $e) { if (isset($this->db)) { $this->db->query('ROLLBACK'); } $this->ajaxReturn(array('result' => 'failure', 'message' => $e->getMessage())); } }
public static function hasNewMail($profile = null) { $profileId = 0; try { if (empty($profile)) { $name = self::getName(); $p = new Profile(array('login_name' => $name)); $profileId = $p->getId(); } else { $profileId = $profile->getId(); } $m = fRecordSet::build('Mail', array('receiver=' => $profileId, 'read=' => 0), array('timestamp' => 'desc'))->count(); return $m; } catch (fNotFoundException $e) { return 0; } }
public function filterMemberIdByProfile($ids, $column, $value, Profile $item, $publicFlag = 1) { $_result = array(); $q = Doctrine::getTable('MemberProfile')->createQuery('m'); $q = opFormItemGenerator::filterSearchQuery($q, 'm.' . $column, $value, $item->toArray())->select('m.member_id')->andWhere('m.profile_id = ?', $item->getId()); if (is_integer($publicFlag)) { if ($item->isMultipleSelect() && $item->getFormType() !== 'date') { $q->addFrom('MemberProfile pm')->andWhere('m.tree_key = pm.id')->andWhere('pm.public_flag <= ?', $publicFlag); } else { $q->andWhere('m.public_flag <= ?', $publicFlag); } } $list = $q->execute(); foreach ($list as $value) { $_result[] = $value->getMemberId(); } if (is_array($ids)) { $ids = array_values(array_intersect($ids, $_result)); } else { $ids = array_values($_result); } return $ids; }
public function filterMemberIdByProfile($ids, $column, $value, Profile $item, $publicFlag = 1) { $_result = array(); $q = Doctrine::getTable('MemberProfile')->createQuery('m'); $q = opFormItemGenerator::filterSearchQuery($q, 'm.' . $column, $value, $item->toArray())->select('m.member_id')->andWhere('m.profile_id = ?', $item->getId()); $isCheckPublicFlag = is_integer($publicFlag); if (!$item->getIsEditPublicFlag()) { if (ProfileTable::PUBLIC_FLAG_SNS == $item->getDefaultPublicFlag() || ProfileTable::PUBLIC_FLAG_WEB == $item->getDefaultPublicFlag()) { $isCheckPublicFlag = false; } else { return array(); } } if ($isCheckPublicFlag) { $publicFlags = (array) $publicFlag; if (1 == $publicFlag) { $publicFlags[] = 4; } if ($item->isMultipleSelect() && 'date' !== $item->getFormType()) { $q->addFrom('MemberProfile pm')->andWhere('m.tree_key = pm.id')->andWhereIn('pm.public_flag', $publicFlags); } else { $q->andWhereIn('m.public_flag', $publicFlags); } } $list = $q->execute(); foreach ($list as $v) { $_result[] = $v->getMemberId(); } if (is_array($ids)) { $ids = array_values(array_intersect($ids, $_result)); } else { $ids = array_values($_result); } if ($isCheckPublicFlag && 'op_preset_birthday' === $item->getName()) { if ('%-' !== substr($value, 0, 2)) { $ids = $this->filterMemberIdsByAgePublicFlag($ids); } } return $ids; }
protected function save($profileData) { //create the profile object require 'classes/profile.php'; $profile = new Profile($profileData, $this->configDb); //validate the profile if (!$profile->isValid()) { $this->viewModel->set("success", false); $this->viewModel->set("message", $profile->getErrorMessage()); return $this->viewModel; } //save the profile in the config db try { $query = $this->configDb->prepare("\n REPLACE INTO profiles (id, profileName, dbODBC, dbUser, dbPassword) \n VALUES (:id, :profileName, :dbODBC, :dbUser, :dbPassword)"); $query->bindValue(':id', $profile->getId()); $query->bindValue(':profileName', $profile->getProfileName()); $query->bindValue(':dbODBC', $profile->getDbODBC()); $query->bindValue(':dbUser', $profile->getDbUser()); $query->bindValue(':dbPassword', $profile->getDbPassword()); $query->execute(); $this->viewModel->set("success", true); if (!isset($profileData['id'])) { $this->viewModel->set("message", "Success - you have created a new profile."); } else { $this->viewModel->set("message", "Success - you have updated the profile."); } return $this->viewModel; } catch (PDOException $e) { $this->viewModel->set("success", false); $this->viewModel->set("message", $e->getMessage()); return $this->viewModel; } }