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; }
static function cloneProfile(Profile $prof) { $plugprof = new self(); if ($plugprof->getFromDB($prof->input['_old_id'])) { $input = ToolBox::addslashes_deep($plugprof->fields); $input['profile'] = ToolBox::addslashes_deep($prof->getName()); $input['id'] = $prof->getID(); $plugprof->add($input); } }
public static function executeProfile(Profile $profile, AbstractEyeosUser $user) { $path = SYSTEM_SKEL_PATH . '/' . USERS_DIR . '/profiles/' . utf8_basename($profile->getName()) . '/scripts/'; $directory = new DirectoryIterator($path); foreach ($directory as $fileInfo) { $fileInfoName = $fileInfo->getFileName(); if (!$fileInfo->isDot() && $fileInfoName != '.svn') { require_once $path . $fileInfoName; } } }
/** * View all users connections * @param int $user * @return void */ private function viewAll($user) { if ($this->registry->getObject('authenticate')->isLoggedIn()) { require_once FRAMEWORK_PATH . 'models/relationships.php'; $relationships = new Relationships($this->registry); $all = $relationships->getByUser($user, false, 0); $this->registry->getObject('template')->buildFromTemplates('header.tpl.php', 'friends/all.tpl.php', 'footer.tpl.php'); $this->registry->getObject('template')->getPage()->addTag('all', array('SQL', $all)); require_once FRAMEWORK_PATH . 'models/profile.php'; $p = new Profile($this->registry, $user); $name = $p->getName(); $this->registry->getObject('template')->getPage()->addTag('connecting_name', $name); } else { $this->registry->errorPage('Please login', 'Please login to view a users connections'); } }
/** * Set common template tags for all profile aspects * @param int $user the user id * @return void */ private function commonTemplateTags($user) { // get a random sample of 6 friends. require_once FRAMEWORK_PATH . 'models/relationships.php'; $relationships = new Relationships($this->registry); $cache = $relationships->getByUser($user, true, 6); $this->registry->getObject('template')->getPage()->addTag('profile_friends_sample', array('SQL', $cache)); // get the name and photo of the user require_once FRAMEWORK_PATH . 'models/profile.php'; $profile = new Profile($this->registry, $user); $name = $profile->getName(); $photo = $profile->getPhoto(); $uid = $profile->getID(); $this->registry->getObject('template')->getPage()->addTag('profile_name', $name); $this->registry->getObject('template')->getPage()->addTag('profile_photo', $photo); $this->registry->getObject('template')->getPage()->addTag('profile_user_id', $uid); // clear the profile $profile = ""; }
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; }
/** * @param Profile $profile */ public function add(Profile $profile) { $this->profiles[$profile->getName()] = $profile; }
private function viewAll($user) { if ($this->registry->getObject('authenticate')->isLoggedIn() == true) { $rel = new RelationsGet($this->registry); $all = $rel->getByUser($user, false, 0); $this->registry->getObject('template')->buildFromTemplate('header.php', 'relations_all.php', 'footer.php'); //echo $all; $this->registry->getObject('template')->getPage()->addTag('all', array('SQL', $all)); $profile = new Profile($this->registry, $user); $name = $profile->getName(); $this->registry->getObject('template')->getPage()->addTag('connecting_name', $name); } else { $this->registry->errorPage('Error', 'Please Login to view connections'); } }
// Law of Demter (Tell, Don't Ask!) // // // The method on an object is allowed to interact with the following: // // 1. Other methods on its object; // 2. Methods on properties of the object; // 3. Methods on arguments passed into the method; // 4. Methods on instances of new objects, created inside of the method. include "User.php"; include "Profile.php"; /** * If we want to get the user's name, through the Profile object, * it should TELL the name, not ASK for it a third party object, * in our case the User object. * * So, without the law of Demeter in mind, the code would look like this: */ $user = new User("Josh", 29); $userProfile = new Profile($user, "/img/josh.jpg"); echo $userProfile->getUser()->getName(); /** * In the above example, we ASK the User object to give us it's name. * * Now, we'll make the Profile object TELL the user's name: */ echo $userProfile->getName(); /** * The above row is the law of Demeter in action. */