function add_subscribers(ProjectDataObject $object)
 {
     if (logged_user()->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $log_info = "";
     $subscribers = array_var($_POST, 'subscribers');
     $object->clearSubscriptions();
     if (is_array($subscribers)) {
         foreach ($subscribers as $key => $checked) {
             $user_id = substr($key, 5);
             if ($checked == "checked") {
                 $user = Users::findById($user_id);
                 if ($user instanceof User) {
                     $object->subscribeUser($user);
                     $phone_num = Users::getPhoneNumberCustomProperty($user_id);
                     $sms_obj = new SmsController();
                     $sms_obj->prepareSubscriberSms($user->getDisplayName(), $object->getTitle(), get_class($object));
                     $sms_obj->sendSms($phone_num);
                     $log_info .= ($log_info == "" ? "" : ",") . $user->getId();
                 }
             }
         }
         if ($log_info != "") {
             ApplicationLogs::createLog($object, $object->getWorkspaces(), ApplicationLogs::ACTION_SUBSCRIBE, false, true, true, $log_info);
         }
     }
 }
Esempio n. 2
0
 /**
 * Return object connected with this action, that is not equal to the one received
 *
 * @access public
 * @param  ProjectDataObject $object
 * @return ProjectDataObject
 */
 function getOtherObject($object) {
   if (($object->getObjectId()!= $this->getObjectId()) ) {
   		return Objects::findObject($this->getObjectId());
   } else {
   		return Objects::findObject($this->getRelObjectId());
   }
 } // getObject
 /**
  * Return object connected with this action, that is not equal to the one received
  *
  * @access public
  * @param  ProjectDataObject $object
  * @return ProjectDataObject
  */
 function getOtherObject($object)
 {
     if (get_class($object->manager()) != $this->getObjectManager() || $object->getObjectId() != $this->getObjectId()) {
         return get_object_by_manager_and_id($this->getObjectId(), $this->getObjectManager());
     } else {
         return get_object_by_manager_and_id($this->getRelObjectId(), $this->getRelObjectManager());
     }
 }
Esempio n. 4
0
	static function DeleteFromIndex(ProjectDataObject $object, $commitOnEnd = true){
		$term = new Zend_Search_Lucene_Index_Term(get_class($object->manager()) . $object->getObjectId(), 'id');
		
    	foreach (self::GetIndex()->termDocs($term) as $id)
        	self::GetIndex()->delete($id);
        
        if ($commitOnEnd)
        	self::GetIndex()->commit();
	}
Esempio n. 5
0
 /**
  * Return tag names as array for specific object
  *
  * @access public
  * @param ProjectDataObject $object
  * @param string $manager_class
  * @return array
  */
 function getTagNamesByObject(ProjectDataObject $object, $manager_class)
 {
     $rows = DB::executeAll('SELECT `tag` FROM ' . self::instance()->getTableName(true) . ' WHERE `rel_object_id` = ? AND `rel_object_manager` = ? ORDER BY `tag`', $object->getId(), $manager_class);
     if (!is_array($rows)) {
         return null;
     }
     $tags = array();
     foreach ($rows as $row) {
         $tags[] = $row['tag'];
     }
     return $tags;
 }
 /**
  * This function saves the wiki page 
  *
  * @return void
  */
 function save()
 {
     if (instance_of($this->new_revision, 'Revision')) {
         // Increase the page revision number
         $this->setColumnValue('revision', $this->getColumnValue('revision') + 1);
         // Remove any other pages in this project which have the default page status
         if ($this->isColumnModified('project_index') && $this->getColumnValue('project_index') == 1) {
             $sql = 'UPDATE ' . $this->getTableName(true) . ' SET `project_index` = 0 WHERE `project_id` = ' . $this->getProjectId();
             DB::execute($sql);
         }
         // Remove any other pages in this project which have sidebar status
         if ($this->isColumnModified('project_sidebar') && $this->getColumnValue('project_sidebar') == 1) {
             $sql = 'UPDATE ' . $this->getTableName(true) . ' SET `project_sidebar` = 0 WHERE `project_id` = ' . $this->getProjectId();
             DB::execute($sql);
         }
         // Save this page with the new revision id
         parent::save();
         // Set the revisions's page Id
         $this->new_revision->setPageId($this->getId());
         //Set the project Id
         $this->new_revision->setProjectId($this->getProjectId());
         // Set the revision number in the revision object
         $this->new_revision->setRevision($this->getColumnValue('revision'));
         // If we have made a new revision of this page, then save the revision
         $this->new_revision->save();
     } else {
         // We haven't made a new revision, so we shouldn't update this page
         return false;
     }
 }
Esempio n. 7
0
 /**
  * Drop comments by object
  *
  * @param ProjectDataObject
  * @return boolean
  */
 static function dropCommentsByObject(ProjectDataObject $object)
 {
     return Comments::delete(array('`rel_object_manager` = ? AND `rel_object_id` = ?', get_class($object->manager()), $object->getObjectId()));
 }
 /**
  * Update is_private flag value for all previous related log entries related with specific object
  *
  * This method is called whenever we need to add new log entry. It will keep old log entries related to that specific
  * object with current is_private flag value by updating all of the log entries to new value.
  *
  * @param ProjectDataObject $object
  * @return boolean
  */
 static function setIsPrivateForObject(ProjectDataObject $object)
 {
     return DB::execute('UPDATE ' . ApplicationLogs::instance()->getTableName(true) . ' SET `is_private` = ?  WHERE `rel_object_id` = ?  AND `rel_object_manager` = ?', $object->isPrivate(), $object->getObjectId(), get_class($object->manager()));
     // execute
 }
 /**
  * Clear subscriptions by object
  *
  * @param ProjectDataObject $message
  * @return boolean
  */
 static function clearByObject(ProjectDataObject $object)
 {
     return ObjectSubscriptions::delete('`object_id` = ' . DB::escape($object->getId()) . ' AND `object_manager` = ' . DB::escape(get_class($object->manager())));
 }
Esempio n. 10
0
/**
 * Show object comments block
 *
 * @param ProjectDataObject $object Show comments of this object
 * @return null
 */
function render_object_comments(ProjectDataObject $object)
{
    if (!$object->isCommentable()) {
        return '';
    }
    tpl_assign('__comments_object', $object);
    return tpl_fetch(get_template_path('object_comments', 'comment'));
}
 /**
  * Clear all relations by object
  *
  * @param ProjectDataObject
  * @return boolean
  */
 static function clearRelationsByObject(ProjectDataObject $object)
 {
     return self::delete(array('`rel_object_manager` = ? AND `rel_object_id` = ?', get_class($object->manager()), $object->getObjectId()));
 }
 /**
  * Copies custom properties from an object
  * @param ProjectDataObject $object
  */
 function copyCustomPropertiesFrom($object)
 {
     $properties = $object->getCustomProperties();
     foreach ($properties as $property) {
         $copy = new ObjectProperty();
         $copy->setPropertyName($property->getPropertyName());
         $copy->setPropertyValue($property->getPropertyValue());
         $copy->setObject($this);
         $copy->save();
     }
 }
 static function clearByObjectAndUser(ProjectDataObject $object, User $user, $include_subscribers = false)
 {
     if ($include_subscribers) {
         $usercond = '(`user_id` = ' . DB::escape($user->getId()) . ' OR `user_id` = 0)';
     } else {
         $usercond = '`user_id` = ' . DB::escape($user->getId());
     }
     return ObjectReminders::delete('`object_id` = ' . DB::escape($object->getId()) . ' AND `object_manager` = ' . DB::escape(get_class($object->manager())) . " AND {$usercond}");
 }
Esempio n. 14
0
 /**
  * Drop timeslots by object
  *
  * @param ProjectDataObject
  * @return boolean
  */
 static function dropTimeslotsByObject(ProjectDataObject $object)
 {
     return self::delete(array('`object_manager` = ? AND `object_id` = ?', get_class($object->manager()), $object->getObjectId()));
 }
Esempio n. 15
0
 static function getAddTimespanUrl(ProjectDataObject $object)
 {
     return get_url('timeslot', 'add_timespan', array('object_id' => $object->getObjectId(), 'object_manager' => get_class($object->manager())));
     // get_url
 }
Esempio n. 16
0
 /**
  * Return add comment URL for specific object
  *
  * @param ProjectDataObject $object
  * @return string
  */
 static function getAddUrl(ProjectDataObject $object)
 {
     return get_url('comment', 'add', array('object_id' => $object->getObjectId(), 'object_manager' => get_class($object->manager()), 'active_project' => $object->getProject()->getId()));
     // get_url
 }
 /**
  * Reaturn pending handins that an object has
  *
  * @param ProjectDataObject $object
  * @return array
  */
 static function getPendingHandinsByObject(ProjectDataObject $object)
 {
     return self::getAllHandinsByIdAndManager($object->getObjectId(), get_class($object->manager()), true);
 }
Esempio n. 18
0
	/**
	 * Return add BillingCategory URL for specific object
	 *
	 * @param ProjectDataObject $object
	 * @return string
	 */
	static function getAddUrl(ProjectDataObject $object) {
		return get_url('billing', 'add', array(
        'object_id' => $object->getObjectId(),
        'object_manager' => get_class($object->manager())
		)); // get_url
	} // getAddUrl
Esempio n. 19
0
 function giveAccessToObject(ProjectDataObject $object)
 {
     $ou = new ObjectUserPermission();
     $ou->setObjectId($object->getId());
     $ou->setObjectManager($object->getObjectManagerName());
     $ou->setUserId($this->getId());
     $ou->setReadPermission(true);
     $ou->setWritePermission(false);
     $ou->save();
 }
Esempio n. 20
0
/**
 * Render the options available for the given object
 *
 * @param ProjectDataObject $object
 * @return string
 */
function render_object_options(ProjectDataObject $object, $additional_options = null)
{
    $options = array();
    if ($object->canEdit(logged_user())) {
        $options[] = '<a href="' . $object->getEditUrl() . '">' . lang('edit') . '</a>';
    }
    // if
    if ($object->canView(logged_user())) {
        $options[] = '<a href="' . $object->getViewUrl() . '">' . lang('view') . '</a>';
    }
    // if
    if ($object->canDelete(logged_user())) {
        $options[] = '<a href="' . $object->getDeleteUrl() . '">' . lang('delete') . '</a>';
    }
    // if
    if (is_array($additional_options)) {
        $options = array_merge($options, $additional_options);
    }
    if (count($options)) {
        tpl_assign('options', $options);
        return tpl_fetch(get_template_path('object_options', 'application'));
    }
    return '';
}
Esempio n. 21
0
/**
 * Creates a button that shows an object picker to link the object given by $object with the one selected in
 * the it.
 *
 * @param ProjectDataObject $object
 */
function render_link_to_object($object, $text = null, $reload = false)
{
    require_javascript("og/ObjectPicker.js");
    $id = $object->getId();
    $manager = get_class($object->manager());
    if ($text == null) {
        $text = lang('link object');
    }
    $reload_param = $reload ? '&reload=1' : '';
    $result = '';
    $result .= '<a href="#" class="link-ico ico-add" onclick="og.ObjectPicker.show(function (data) {' . 'if (data) {' . 'var objects = \'\';' . 'for (var i=0; i < data.length; i++) {' . 'if (objects != \'\') objects += \',\';' . 'objects += data[i].data.manager + \':\' + data[i].data.object_id;' . '}' . ' og.openLink(\'' . get_url("object", "link_object") . '&object_id=' . $id . '&manager=' . $manager . $reload_param . '&objects=\' + objects' . ($reload ? ',{callback: function(){og.redrawLinkedObjects(' . $object->getId() . ', \'' . get_class($object->manager()) . '\')}}' : '') . ');' . '}' . '})" id="object_linker">';
    $result .= $text;
    $result .= '</a>';
    return $result;
}