/**
  * @param ByTimeWorkflowInQueue $model
  * @return string
  */
 public static function renderSummaryContent(ByTimeWorkflowInQueue $model)
 {
     $params = array('label' => strval($model->savedWorkflow), 'wrapLabel' => false);
     $moduleClassName = $model->getModuleClassName();
     $moduleId = $moduleClassName::getDirectoryName();
     $element = new DetailsLinkActionElement('default', $moduleId, $model->savedWorkflow->id, $params);
     return $element->render() . static::resolveModelAndContent($model);
 }
 /**
  * @param RedBeanModel $model
  * @return string
  */
 protected static function resolveModelContent(RedBeanModel $model)
 {
     $security = new DetailsActionSecurity(Yii::app()->user->userModel, $model);
     if ($security->canUserPerformAction()) {
         $params = array('label' => strval($model), 'wrapLabel' => false);
         $moduleClassName = $model->getModuleClassName();
         $moduleId = $moduleClassName::getDirectoryName();
         $relatedModelElement = new DetailsLinkActionElement('default', $moduleId, $model->id, $params);
         return $relatedModelElement->render();
     }
 }
Exemple #3
0
 protected static function renderModelStringContent(RedBeanModel $model, $redirectUrl)
 {
     assert('is_string($redirectUrl) || $redirectUrl == null');
     $modelDisplayString = strval($model);
     if (strlen($modelDisplayString) > 200) {
         $modelDisplayString = substr($modelDisplayString, 0, 200) . '...';
     }
     if (get_class($model) == 'Task') {
         $modelDisplayString = '<span style="text-decoration:line-through;">' . $modelDisplayString . '</span>';
     }
     $params = array('label' => $modelDisplayString, 'redirectUrl' => $redirectUrl, 'wrapLabel' => false);
     $moduleClassName = $model->getModuleClassName();
     $moduleId = $moduleClassName::getDirectoryName();
     $element = new DetailsLinkActionElement('default', $moduleId, $model->id, $params);
     return $element->render();
 }
 /**
  * @param RedBeanModel $model
  * @param string $castDownModelClassName
  * @return null|string
  */
 protected static function getActivityItemsStringContentByModelClassName(RedBeanModel $model, $castDownModelClassName, $stateMetadataAdapter = 'StateMetadataAdapter')
 {
     assert('is_string($castDownModelClassName)');
     assert('is_string($stateMetadataAdapter)');
     $existingModels = array();
     $modelDerivationPathToItem = RuntimeUtil::getModelDerivationPathToItem($castDownModelClassName);
     foreach ($model->activityItems as $item) {
         try {
             $castedDownModel = $item->castDown(array($modelDerivationPathToItem));
             if (get_class($castedDownModel) == $castDownModelClassName) {
                 if (strval($castedDownModel) != null) {
                     $params = array('label' => strval($castedDownModel), 'wrapLabel' => false);
                     $moduleClassName = $stateMetadataAdapter::getModuleClassNameByModel($castedDownModel);
                     $moduleId = $moduleClassName::getDirectoryName();
                     $element = new DetailsLinkActionElement('default', $moduleId, $castedDownModel->id, $params);
                     $existingModels[] = $element->render();
                 }
             }
         } catch (NotFoundException $e) {
             //do nothing
         }
     }
     return self::resolveStringValueModelsDataToStringContent($existingModels);
 }
 public static function getRecipientsContent(RedBeanOneToManyRelatedModels $recipients, $type = null, $additionalParams = array())
 {
     assert('$type == null || $type == EmailMessageRecipient::TYPE_TO ||
                 EmailMessageRecipient::TYPE_CC || EmailMessageRecipient::TYPE_BCC');
     $existingModels = array();
     if ($recipients->count() == 0) {
         return;
     }
     foreach ($recipients as $recipient) {
         if ($type == null || $recipient->type == $type) {
             $existingPersonsOrAccounts = array();
             if ($recipient->personsOrAccounts->count() == 0) {
                 $existingPersonsOrAccounts[] = $recipient->toAddress . ' ' . $recipient->toName;
             } else {
                 foreach ($recipient->personsOrAccounts as $personOrAccount) {
                     try {
                         $castedDownModel = self::castDownItem($personOrAccount);
                         if (strval($castedDownModel) != null) {
                             $params = array('label' => strval($castedDownModel), 'wrapLabel' => false);
                             if (get_class($castedDownModel) == 'Contact') {
                                 $moduleClassName = ContactsStateMetadataAdapter::getModuleClassNameByModel($castedDownModel);
                             } else {
                                 $moduleClassName = $castedDownModel->getModuleClassName();
                             }
                             $moduleId = $moduleClassName::getDirectoryName();
                             $element = new DetailsLinkActionElement('default', $moduleId, $castedDownModel->id, array_merge($params, $additionalParams));
                             $existingPersonsOrAccounts[] = $element->render();
                         }
                     } catch (AccessDeniedSecurityException $e) {
                         $existingPersonsOrAccounts[] = $recipient->toAddress . ' ' . $recipient->toName;
                     } catch (NotSupportedException $e) {
                         //If the personOrAccount no longer exists or something else isn't right with the model
                         $existingPersonsOrAccounts[] = $recipient->toAddress . ' ' . $recipient->toName;
                     }
                 }
             }
             $recipientString = self::resolveStringValueModelsDataToStringContent($existingPersonsOrAccounts);
             if (count($existingPersonsOrAccounts) > 1) {
                 $existingModels[] = $recipient->toAddress . '(' . $recipientString . ')';
             } else {
                 $existingModels[] = $recipientString;
             }
         }
     }
     return self::resolveStringValueModelsDataToStringContent($existingModels);
 }
 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;
 }
 /**
  * The content to be displayed in the MashableInboxListView row
  * @param RedBeanModel $model
  * @return string
  */
 public function getModelStringContent(RedBeanModel $model)
 {
     $modelDisplayString = strval($model);
     $params = array('label' => $modelDisplayString, 'wrapLabel' => false);
     $moduleClassName = $model->getModuleClassName();
     $moduleId = $moduleClassName::getDirectoryName();
     $element = new DetailsLinkActionElement('default', $moduleId, $model->id, $params);
     $content = $element->render();
     $lastCommentNumber = count($model->comments) - 1;
     if ($lastCommentNumber > 0) {
         $content .= ZurmoHtml::tag('span', array("class" => "last-comment"), $model->comments[$lastCommentNumber]->description);
     }
     return $content;
 }
 public static function getRecipientsContent(RedBeanOneToManyRelatedModels $recipients, $type = null)
 {
     assert('$type == null || $type == EmailMessageRecipient::TYPE_TO ||
                 EmailMessageRecipient::TYPE_CC || EmailMessageRecipient::TYPE_BCC');
     $existingModels = array();
     if ($recipients->count() == 0) {
         return;
     }
     foreach ($recipients as $recipient) {
         if ($type == null || $recipient->type == $type) {
             if ($recipient->personOrAccount->id < 0) {
                 $existingModels[] = $recipient->toAddress . ' ' . $recipient->toName;
             } else {
                 $castedDownModel = self::castDownItem($recipient->personOrAccount);
                 try {
                     if (strval($castedDownModel) != null) {
                         $params = array('label' => strval($castedDownModel), 'wrapLabel' => false);
                         $moduleClassName = $castedDownModel->getModuleClassName();
                         $moduleId = $moduleClassName::getDirectoryName();
                         $element = new DetailsLinkActionElement('default', $moduleId, $castedDownModel->id, $params);
                         $existingModels[] = $element->render();
                     }
                 } catch (AccessDeniedSecurityException $e) {
                     $existingModels[] = $recipient->toAddress . ' ' . $recipient->toName;
                 }
             }
         }
     }
     return self::resolveStringValueModelsDataToStringContent($existingModels);
 }