Пример #1
0
 public function addComment(Core_Model_Item_Abstract $resource, Core_Model_Item_Abstract $poster, $body)
 {
     $table = $this->getCommentTable();
     $row = $table->createRow();
     if (isset($row->resource_type)) {
         $row->resource_type = $resource->getType();
     }
     $row->resource_id = $resource->getIdentity();
     if ($poster->getIdentity() > 0) {
         $row->poster_type = $poster->getType();
         $row->poster_id = $poster->getIdentity();
     } else {
         $row->poster_type = 'user';
         $row->poster_id = 0;
         $row->poster_name = $poster->displayname;
         $row->poster_email = $poster->email;
     }
     $row->creation_date = date('Y-m-d H:i:s');
     $row->body = $body;
     $row->save();
     if (isset($resource->comment_count)) {
         $resource->comment_count++;
         $resource->save();
     }
     return $row;
 }
Пример #2
0
 public function editActivity(Core_Model_Item_Abstract $action, Core_Model_Item_Abstract $subject, Core_Model_Item_Abstract $object, $type, $body = null, array $params = null)
 {
     // Disabled or missing type
     $typeInfo = $this->getActionType($type);
     if (!$typeInfo || !$typeInfo->enabled) {
         return;
     }
     // User disabled publishing of this type
     $actionSettingsTable = Engine_Api::_()->getDbtable('actionSettings', 'activity');
     if (!$actionSettingsTable->checkEnabledAction($subject, $type)) {
         return;
     }
     // Edit action
     $action->body = $body;
     $action->params = $params;
     $action->save();
     // Remove all privacies
     $streamTable = Engine_Api::_()->getDbtable('stream', 'activity');
     $action_id = $action->getIdentity();
     $streamTable->delete("action_id = {$action_id}");
     // Add bindings
     $this->addActivityBindings($action, $type, $subject, $object);
     // We want to update the subject
     if (isset($subject->modified_date)) {
         $subject->modified_date = date('Y-m-d H:i:s');
         $subject->save();
     }
     return $action;
 }
Пример #3
0
 public function remove(Core_Model_Item_Abstract $idea, Core_Model_Item_Abstract $poster)
 {
     $row = $this->getVote($idea->getIdentity(), $poster->getIdentity());
     if (null !== $row) {
         $row->delete();
         if (isset($idea->vote_count)) {
             $idea->vote_count--;
             $idea->save();
         }
     }
     return $this;
 }
Пример #4
0
 public function clearStatus(Core_Model_Item_Abstract $resource)
 {
     // Update resource if necessary
     $resourceModified = false;
     if (isset($resource->status)) {
         $resourceModified = true;
         $resource->status = '';
     }
     if (isset($resource->status_date)) {
         $resourceModified = true;
         $resource->status_date = '00-00-0000';
     }
     if ($resourceModified) {
         $resource->save();
     }
     return $this;
 }
Пример #5
0
 public function removeAllMembers(Core_Model_Item_Abstract $resource)
 {
     $this->getTable()->delete(array('resource_id = ?' => $resource->getIdentity()));
     if (isset($resource->member_count)) {
         $resource->member_count = 0;
         $resource->save();
     }
     return $this;
 }