PHP Method User::getClassId, codiad Code Examples

This page contains top rated real world PHP examples of method User::getClassId from package codiad extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: Conversation.php Project: youprofit/Zurmo
0
 /**
  * Given a user get the count of conversations that have unread comments.
  * @param object $user User
  */
 public static function getUnreadCountByUser(User $user)
 {
     $searchAttributeData = array();
     $searchAttributeData['clauses'] = array(1 => array('attributeName' => 'ownerHasReadLatest', 'operatorType' => 'doesNotEqual', 'value' => (bool) 1), 2 => array('attributeName' => 'owner', 'operatorType' => 'equals', 'value' => $user->id), 3 => array('attributeName' => 'conversationParticipants', 'relatedAttributeName' => 'person', 'operatorType' => 'equals', 'value' => $user->getClassId('Item')), 4 => array('attributeName' => 'conversationParticipants', 'relatedAttributeName' => 'hasReadLatest', 'operatorType' => 'doesNotEqual', 'value' => (bool) 1));
     $searchAttributeData['structure'] = '((1 and 2) or (3 and 4))';
     $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('Conversation');
     $where = RedBeanModelDataProvider::makeWhere('Conversation', $searchAttributeData, $joinTablesAdapter);
     return self::getCount($joinTablesAdapter, $where, null, true);
 }
Example #2
Show file File: ConversationParticipantsUtil.php Project: RamaKavanan/InitialVersion
0
 /**
  * Given a Conversation and User, determine if the user is already a conversationParticipant.
  * @param Conversation $model
  * @param User $user
  * @return boolean
  */
 public static function isUserAParticipant(Conversation $model, User $user)
 {
     if ($model->conversationParticipants->count() > 0) {
         foreach ($model->conversationParticipants as $participant) {
             if ($participant->person->getClassId('Item') == $user->getClassId('Item')) {
                 return true;
             }
         }
     }
     return false;
 }
Example #3
Show file File: AllPermissionsOptimizationCache.php Project: RamaKavanan/InitialVersion
0
 /**
  * @param User $user
  * @param array $mungeIds
  */
 public static function cacheMungeIdsByUser(User $user, array $mungeIds)
 {
     if ($user->getClassId('Permitable') == 0) {
         return;
     }
     $userModelIdentifier = $user->getModelIdentifier();
     if (static::supportsAndAllowsPhpCaching()) {
         static::$mungeIdsByUser[$user->id] = $mungeIds;
     }
     if (static::supportsAndAllowsMemcache()) {
         $prefix = static::getCachePrefix($userModelIdentifier) . static::$mungeIdsCachePrefix;
         static::cacheValueAndChecksum($prefix . $userModelIdentifier, $mungeIds);
     }
 }
Example #4
Show file File: TasksNotificationUtil.php Project: maruthisivaprasad/zurmo
0
 /**
  * Gets notification subscribers
  * @param Task $task
  * @param $action
  * @param User $relatedUser
  * @return array
  */
 public static function resolvePeopleToSendNotification(Task $task, $action, User $relatedUser = null)
 {
     assert('is_string($action)');
     $peopleToSendNotification = array();
     if ($action == self::TASK_NEW || $action == self::TASK_OWNER_CHANGE || $action == self::TASK_STATUS_BECOMES_REJECTED) {
         $peopleToSendNotification[] = $task->owner;
     } elseif ($action == self::TASK_STATUS_BECOMES_AWAITING_ACCEPTANCE) {
         $peopleToSendNotification[] = $task->requestedByUser;
     } elseif ($action == self::TASK_STATUS_BECOMES_COMPLETED || $action == self::TASK_NEW_COMMENT) {
         $peopleToSendNotification = TasksUtil::getTaskSubscribers($task);
         if ($action == self::TASK_NEW_COMMENT && $relatedUser != null) {
             foreach ($peopleToSendNotification as $key => $person) {
                 if ($person->getClassId('Item') == $relatedUser->getClassId('Item')) {
                     unset($peopleToSendNotification[$key]);
                 }
             }
         }
         if ($action == self::TASK_STATUS_BECOMES_COMPLETED && Yii::app()->user->userModel->id == $task->owner->id) {
             foreach ($peopleToSendNotification as $key => $person) {
                 if ($person->getClassId('Item') == $task->owner->getClassId('Item')) {
                     unset($peopleToSendNotification[$key]);
                 }
             }
         }
     }
     return $peopleToSendNotification;
 }
Example #5
Show file File: GamePoint.php Project: youprofit/Zurmo
0
 /**
  * Performance function to grab all summation data by type for a given user.
  * @param User $user
  * @return array of summation points indexed by the level type
  */
 public static function getSummationPointsDataByUserIndexedByLevelType(User $user)
 {
     assert('$user->id > 0');
     $sql = "select type, sum(value) sum from gamepoint where person_item_id = " . $user->getClassId('Item') . " group by type";
     $rows = R::getAll($sql);
     $indexedData = array();
     foreach ($rows as $row) {
         $indexedData[$row['type']] = $row['sum'];
     }
     return $indexedData;
 }
Example #6
Show file File: ConversationsUtil.php Project: RamaKavanan/InitialVersion
0
 /**
  * @param Conversation $conversation
  * @param User $user
  * @return A|bool
  */
 public static function hasUserReadConversationLatest(Conversation $conversation, User $user)
 {
     assert('$conversation->id > 0');
     assert('$user->id > 0');
     if ($user->isSame($conversation->owner)) {
         return $conversation->ownerHasReadLatest;
     } else {
         foreach ($conversation->conversationParticipants as $position => $participant) {
             if ($participant->person->getClassId('Item') == $user->getClassId('Item')) {
                 return $participant->hasReadLatest;
             }
         }
     }
     return false;
 }
Example #7
Show file File: MissionsUtil.php Project: youprofit/Zurmo
0
 /**
  * Given a Mission and the User that created the new comment
  * return the people on the mission to send new notification to
  * @param Mission $mission
  * @param User $user
  * @return Array $peopleToSendNotification
  */
 public static function resolvePeopleToSendNotificationToOnNewComment(Mission $mission, User $user)
 {
     $usersToSendNotification = User::getAll();
     $peopleToSendNotification = array();
     foreach ($usersToSendNotification as $userToSendNotification) {
         if ($userToSendNotification->getClassId('Item') != $user->getClassId('Item')) {
             if ($mission->takenByUser->id > 0) {
                 if ($userToSendNotification->getClassId('Item') == $mission->owner->getClassId('Item') || $userToSendNotification->getClassId('Item') == $mission->takenByUser->getClassId('Item')) {
                     $peopleToSendNotification[] = $userToSendNotification;
                 }
             } else {
                 $peopleToSendNotification[] = $userToSendNotification;
             }
         }
     }
     return $peopleToSendNotification;
 }
Example #8
Show file File: MashableInboxRules.php Project: youprofit/Zurmo
0
 /**
  * @param $model
  * @param User $user
  */
 public function markUserAsHavingReadLatestModel($model, User $user)
 {
     $haveNotReadRelationName = $this->getHaveNotReadRelationName();
     foreach ($model->{$haveNotReadRelationName} as $existingPersonWhoHaveNotReadLatest) {
         if ($existingPersonWhoHaveNotReadLatest->person->getClassId('Item') == $user->getClassId('Item')) {
             $this->removePersonWhoHasNotReadLatestToModel($model, $existingPersonWhoHaveNotReadLatest);
         }
     }
     $model->save();
 }
Example #9
Show file File: AllPermissionsOptimizationCache.php Project: maruthisivaprasad/zurmo
0
 /**
  * @param User $user
  * @param array $mungeIds
  */
 public static function cacheMungeIdsByUser(User $user, array $mungeIds)
 {
     if ($user->getClassId('Permitable') == 0) {
         return;
     }
     $userModelIdentifier = $user->getModelIdentifier();
     if (static::supportsAndAllowsPhpCaching()) {
         static::$mungeIdsByUser[$user->id] = $mungeIds;
     }
     if (static::supportsAndAllowsMemcache()) {
         $prefix = static::getCachePrefix($userModelIdentifier) . static::$mungeIdsCachePrefix;
         Yii::app()->cache->set($prefix . $userModelIdentifier, serialize($mungeIds));
     }
 }
Example #10
Show file File: TasksUtil.php Project: RamaKavanan/InitialVersion
0
 /**
  * Given a task and a user, mark that the user has read or not read the latest changes as a task
  * owner, requested by user or subscriber
  * @param Task $task
  * @param User $user
  * @param Boolean $hasReadLatest
  */
 public static function markUserHasReadLatest(Task $task, User $user, $hasReadLatest = true)
 {
     assert('$task->id > 0');
     assert('$user->id > 0');
     assert('is_bool($hasReadLatest)');
     $save = false;
     foreach ($task->notificationSubscribers as $position => $subscriber) {
         if ($subscriber->person->getClassId('Item') == $user->getClassId('Item') && $subscriber->hasReadLatest != $hasReadLatest) {
             $task->notificationSubscribers[$position]->hasReadLatest = $hasReadLatest;
             $save = true;
         }
     }
     if ($save) {
         $task->save();
     }
 }