コード例 #1
0
 public function testProperlyDeletingActivityItems()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $count = ZurmoRedBean::getRow('select count(*) count from activity_item');
     $this->assertEquals(0, $count['count']);
     $account = AccountTestHelper::createAccountByNameForOwner('anAccount', Yii::app()->user->userModel);
     $deleted = $account->delete();
     $this->assertTrue($deleted);
     $count = ZurmoRedBean::getRow('select count(*) count from activity_item');
     $this->assertEquals(0, $count['count']);
     $account2 = AccountTestHelper::createAccountByNameForOwner('anAccount2', Yii::app()->user->userModel);
     $opportunity = OpportunityTestHelper::createOpportunityByNameForOwner('anOpp', Yii::app()->user->userModel);
     $task = TaskTestHelper::createTaskWithOwnerAndRelatedAccount('aTask', Yii::app()->user->userModel, $account2);
     $task->activityItems->add($opportunity);
     $this->assertTrue($task->save());
     $taskId = $task->id;
     $task->forget();
     RedBeansCache::forgetAll();
     $count = ZurmoRedBean::getRow('select count(*) count from activity_item');
     $this->assertEquals(2, $count['count']);
     $deleted = $account2->delete();
     $this->assertTrue($deleted);
     $account2->forget();
     $count = ZurmoRedBean::getRow('select count(*) count from activity_item');
     $this->assertEquals(1, $count['count']);
     RedBeansCache::forgetAll();
     //Make sure things render ok even with the account deleted.
     $content = ActivitiesUtil::renderSummaryContent(Task::getById($taskId), 'someUrl', LatestActivitiesConfigurationForm::OWNED_BY_FILTER_ALL, 'HomeModule');
 }
コード例 #2
0
 public function testRenderSummaryContentWithNote()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $billy = User::getByUsername('billy');
     $account = AccountTestHelper::createAccountByNameForOwner('noteAccount', $super);
     $note = NoteTestHelper::createNoteWithOwnerAndRelatedAccount('aMeeting', $super, $account);
     $content = ActivitiesUtil::renderSummaryContent($note, 'someUrl', LatestActivitiesConfigurationForm::OWNED_BY_FILTER_ALL, 'HomeModule');
     $content = ActivitiesUtil::renderSummaryContent($note, 'someUrl', LatestActivitiesConfigurationForm::OWNED_BY_FILTER_USER, 'HomeModule');
     $content = ActivitiesUtil::renderSummaryContent($note, 'someUrl', LatestActivitiesConfigurationForm::OWNED_BY_FILTER_ALL, 'UserModule');
     $content = ActivitiesUtil::renderSummaryContent($note, 'someUrl', LatestActivitiesConfigurationForm::OWNED_BY_FILTER_USER, 'UserModule');
 }
コード例 #3
0
 protected function renderControlEditable()
 {
     assert('$this->model instanceof Activity');
     $activityItemsModelClassNamesData = ActivitiesUtil::getActivityItemsModelClassNamesDataExcludingContacts();
     return $this->renderElementsForRelationsByRelationsData($activityItemsModelClassNamesData);
 }
コード例 #4
0
ファイル: MeetingsUtil.php プロジェクト: youprofit/Zurmo
 protected static function renderActivityItemsContentsExcludingContacts(Meeting $meeting)
 {
     $activityItemsModelClassNamesData = ActivitiesUtil::getActivityItemsModelClassNamesDataExcludingContacts();
     $content = null;
     foreach ($activityItemsModelClassNamesData as $relationModelClassName) {
         $activityItemForm = null;
         //ASSUMES ONLY A SINGLE ATTACHED ACTIVITYITEM PER RELATION TYPE.
         foreach ($meeting->activityItems as $item) {
             try {
                 $modelDerivationPathToItem = RuntimeUtil::getModelDerivationPathToItem($relationModelClassName);
                 $castedDownModel = $item->castDown(array($modelDerivationPathToItem));
                 if ($content != null) {
                     $content .= ', ';
                 }
                 $content .= strval($castedDownModel);
                 break;
             } catch (NotFoundException $e) {
             }
         }
     }
     if ($content != null) {
         $content .= '<br/>';
     }
     return $content;
 }
コード例 #5
0
 protected static function renderActivityItemsContentsExcludingContacts(Meeting $meeting)
 {
     $activityItemsModelClassNamesData = ActivitiesUtil::getActivityItemsModelClassNamesDataExcludingContacts();
     $content = null;
     foreach ($activityItemsModelClassNamesData as $relationModelClassName) {
         $activityItemForm = null;
         //ASSUMES ONLY A SINGLE ATTACHED ACTIVITYITEM PER RELATION TYPE.
         foreach ($meeting->activityItems as $item) {
             try {
                 $modelDerivationPathToItem = RuntimeUtil::getModelDerivationPathToItem($relationModelClassName);
                 $castedDownModel = $item->castDown(array($modelDerivationPathToItem));
                 if ($content != null) {
                     $content .= '<br/> ';
                 }
                 $params = array('label' => strval($castedDownModel), 'redirectUrl' => null, 'wrapLabel' => false);
                 $moduleClassName = $castedDownModel->getModuleClassName();
                 $moduleId = $moduleClassName::getDirectoryName();
                 $element = new DetailsLinkActionElement('default', $moduleId, $castedDownModel->id, $params);
                 //Render icon
                 $content .= '<i class="icon-' . strtolower(get_class($castedDownModel)) . '"></i> ';
                 $content .= $element->render();
                 break;
             } catch (NotFoundException $e) {
             }
         }
     }
     if ($content != null) {
         $content .= '<br/>';
     }
     return $content;
 }
コード例 #6
0
 public static function castDownActivityItem(Item $activityItem)
 {
     $relationModelClassNames = ActivitiesUtil::getActivityItemsModelClassNames();
     foreach ($relationModelClassNames as $relationModelClassName) {
         try {
             $modelDerivationPathToItem = RuntimeUtil::getModelDerivationPathToItem($relationModelClassName);
             return $activityItem->castDown(array($modelDerivationPathToItem));
         } catch (NotFoundException $e) {
         }
     }
 }
コード例 #7
0
 /**
  * Get meeting attendees from activity items. It returns Contact, Opportunity or Account ids
  * @param $meeting
  * @return array
  * @throws Exception
  */
 protected static function getAttendeesFromActivityItems($meeting)
 {
     $data = array();
     $activityClassNames = ActivitiesUtil::getActivityItemsModelClassNames();
     try {
         foreach ($activityClassNames as $activityClassName) {
             foreach ($meeting->activityItems as $activityItem) {
                 try {
                     $modelDerivationPathToItem = RuntimeUtil::getModelDerivationPathToItem($activityClassName);
                     $castedDownModel = $activityItem->castDown(array($modelDerivationPathToItem));
                     $item = array();
                     $item['id'] = $castedDownModel->id;
                     if ($castedDownModel instanceof Contact) {
                         if ($castedDownModel->primaryEmail->emailAddress != null) {
                             $item['email'] = $castedDownModel->primaryEmail->emailAddress;
                         }
                         $item['firstName'] = $castedDownModel->firstName;
                         $item['lastName'] = $castedDownModel->lastName;
                     } elseif ($castedDownModel instanceof Account || $castedDownModel instanceof Opportunity) {
                         $item['name'] = $castedDownModel->name;
                     }
                     $data[$activityClassName][] = $item;
                 } catch (NotFoundException $e) {
                 }
             }
         }
     } catch (Exception $e) {
         $message = $e->getMessage();
         throw new Exception($message);
     }
     return $data;
 }