示例#1
0
文件: Task.php 项目: sgrove/cothinker
 public function addUser($user_id)
 {
     $user = sfGuardUserPeer::retrieveByPK($user_id);
     if ($user == null) {
         return false;
     }
     $profile = $user->getProfile();
     sfContext::getInstance()->getLogger()->info('Is task already assigned to user?');
     if ($this->isUser($user->getId())) {
         sfContext::getInstance()->getLogger()->info('Task already assigned to user: [' . $this->getName() . ']:[' . $user->getFullName() . ']:[' . $user->getUserId() . ']');
         return true;
     }
     $taskuser = new TaskUser();
     $taskuser->setTaskId($this->getId());
     $taskuser->setUserId($user->getId());
     try {
         $taskuser->save();
     } catch (Exception $e) {
         sfContext::getInstance()->getLogger()->info('Exception assigning task to user, unable to continue');
         return false;
     }
     sfContext::getInstance()->getLogger()->info('Task successfully assigned to user: [' . $this->getName() . ']:[' . $profile->getFullName() . ']:[' . $user->getId() . ']');
     return true;
 }