Exemplo n.º 1
0
 /**
  * @return boolean|quipThread
  */
 public function getThread()
 {
     $threadName = $this->getProperty('thread', '');
     if (empty($threadName)) {
         return false;
     }
     $this->thread = $this->modx->getObject('quipThread', array('name' => $threadName));
     if (empty($this->thread)) {
         $this->thread = $this->modx->newObject('quipThread');
         $this->thread->fromArray(array('name' => $threadName, 'createdon' => strftime('%Y-%m-%d %H:%M:%S', time()), 'moderated' => $this->getProperty('moderate', 0, 'isset'), 'resource' => $this->modx->resource->get('id'), 'idprefix' => $this->getProperty('idprefix', 'qcom')), '', true, true);
         $this->thread->save();
     }
     /* sync properties with thread row values */
     $this->thread->sync($this->getProperties());
     $ps = $this->thread->get('quipreply_call_params');
     if (!empty($ps)) {
         $diff = array_diff_assoc($ps, $this->getProperties());
         if (empty($diff)) {
             $diff = array_diff_assoc($this->getProperties(), $ps);
         }
     }
     if (empty($_REQUEST['quip_thread']) && (!empty($diff) || empty($ps))) {
         /* only sync call params if not on threaded reply page */
         $this->thread->set('quipreply_call_params', $this->getProperties());
         $this->thread->save();
     }
     /* if in threaded reply page, get the original passing values to QuipReply in the thread's main page and use those */
     if (!empty($_REQUEST['quip_thread']) && is_array($ps) && !empty($ps)) {
         $scriptProperties = array_merge($this->getProperties(), $ps);
         $this->setProperties($scriptProperties);
     }
     unset($ps, $diff);
     return $this->thread;
 }
Exemplo n.º 2
0
 public function setUp()
 {
     parent::setUp();
     $this->controller = $this->quip->loadController('ThreadReply');
     $this->assertInstanceOf('QuipThreadReplyController', $this->controller);
     $this->thread = $this->modx->newObject('quipThread');
     $this->thread->fromArray(array('name' => 'unit-test-thread', 'moderated' => true, 'moderator_group' => '', 'moderators' => '', 'notify_emails' => false, 'resource' => 1, 'idprefix' => 'qcom.'), '', true, true);
     $this->thread->save();
     $this->controller->setProperty('thread', 'unit-test-thread');
 }
Exemplo n.º 3
0
 /**
  * Sync the call parameters to the thread
  * @return void
  */
 public function sync()
 {
     /* ensure thread exists, set thread properties if changed
      * (prior to 0.5.0 threads will be handled in install resolver) */
     if (!$this->thread) {
         $this->thread = $this->modx->newObject('quipThread');
         $this->thread->set('name', $this->threadKey);
         $this->thread->set('createdon', strftime('%Y-%m-%d %H:%M:%S'));
         $this->thread->set('moderated', $this->config['moderate']);
         $this->thread->set('moderator_group', $this->config['moderatorGroup']);
         $this->thread->set('moderators', $this->config['moderators']);
         $this->thread->set('resource', $this->getProperty('resource', $this->modx->resource->get('id')));
         $this->thread->set('idprefix', $this->getProperty('idPrefix', 'qcom'));
         $this->thread->set('quip_call_params', $this->scriptProperties);
         if (!empty($this->scriptProperties['moderatorGroup'])) {
             $this->thread->set('moderator_group', $this->scriptProperties['moderatorGroup']);
         }
         /* save existing parameters to comment to preserve URLs */
         $p = $this->modx->request->getParameters();
         unset($p['reported'], $p['quip_start'], $p['quip_limit']);
         $this->thread->set('existing_params', $p);
         $this->thread->save();
     } else {
         /* sync properties with thread row values */
         $this->thread->sync($this->getProperties());
     }
 }
Exemplo n.º 4
0
 public function setUp()
 {
     parent::setUp();
     $this->controller = $this->quip->loadController('Thread');
     $this->assertInstanceOf('QuipThreadController', $this->controller);
     $this->thread = $this->modx->newObject('quipThread');
     $this->thread->fromArray(array('name' => 'unit-test-thread', 'moderated' => true, 'moderator_group' => '', 'moderators' => '', 'notify_emails' => false, 'resource' => 1, 'idprefix' => 'qcom.'), '', true, true);
     $this->thread->save();
     /** @var quipComment $post */
     $post = $this->modx->newObject('quipComment');
     $post->fromArray(array('id' => 12345, 'thread' => 'unit-test-thread', 'rank' => '0000000001', 'author' => $this->modx->user->get('id'), 'body' => 'A test comment.', 'createdon' => strftime('%Y-%m-%d %H:%M:%S'), 'approved' => true, 'approvedon' => strftime('%Y-%m-%d %H:%M:%S'), 'approvedby' => $this->modx->user->get('id'), 'parent' => 0, 'name' => 'Mr. Tester', 'email' => '*****@*****.**', 'website' => 'http://modx.com/', 'ip' => '127.0.0.1', 'deleted' => false, 'resource' => 123456), '', true, true);
     $post->save();
     $this->modx->resource = $this->modx->newObject('modResource');
     $this->modx->resource->fromArray(array('id' => 123456, 'pagetitle' => 'Quip Unit Test Resource', 'alias' => 'quip-unit-test', 'class_key' => 'modDocument', 'hidemenu' => false), '', true, true);
     $this->modx->resource->save();
     $this->resource =& $this->modx->resource;
     $this->controller->setProperty('thread', 'unit-test-thread');
 }