Skip to content
Snippets Groups Projects
class.thread.php 96.8 KiB
Newer Older
  • Learn to ignore specific revisions
  •      * which should, via an AJAX callback, trigger this action to be
         * performed. The URL for this sort of activity is already provided for
         * you via the ::getAjaxUrl() method in this class.
         */
        abstract function getJsStub();
    
    
        /**
         * getAjaxUrl
         *
         * Generate a URL to be used as an AJAX callback. The URL can be used to
         * trigger this thread entry action via the callback.
         *
         * Parameters:
         * $dialog - (bool) used in conjunction with `$.dialog()` javascript
         *      function which assumes the `ajax.php/` should be replace a leading
         *      `#` in the url
         */
    
        function getAjaxUrl($dialog=false) {
    
            return sprintf('%s%s/%d/thread/%d/%s',
    
                $dialog ? '#' : 'ajax.php/',
    
                $this->entry->getThread()->getObjectType() == 'T' ? 'tickets' : 'tasks',
    
                $this->entry->getThread()->getObjectId(),
                $this->entry->getId(),
    
    
        function getTicketsAPI() {
            return new TicketsAjaxAPI();
        }
    
    
        function getTasksAPI() {
            return new TasksAjaxAPI();
        }
    
    
    interface Threadable {
    
        function getThreadId();
        function getThread();
    
        function postThreadEntry($type, $vars, $options=array());
    
    
    /**
     * ThreadActivity
     *
     * Object to thread activity
     *
     */
    class ThreadActivity implements TemplateVariable {
        var $title;
        var $desc;
    
        function __construct($title, $desc) {
            $this->title = $title;
            $this->desc = $desc;
        }
    
        function getTitle() {
            return $this->title;
        }
    
        function getDescription() {
            return $this->desc;
        }
        function asVar() {
            return (string) $this->getTitle();
        }
    
        function getVar($tag) {
            if ($tag && is_callable(array($this, 'get'.ucfirst($tag))))
                return call_user_func(array($this, 'get'.ucfirst($tag)));
    
            return false;
        }
    
        static function getVarScope() {
            return array(
              'title' => __('Activity Title'),
              'description' => __('Activity Description'),
            );
        }
    }