Esempio 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;
 }
Esempio 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');
 }
Esempio n. 3
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');
 }
Esempio n. 4
0
 /**
  * Get and load the thread
  * @return bool|quipThread
  */
 public function getThread()
 {
     $threadName = $this->getProperty('thread', '');
     if (empty($threadName)) {
         return false;
     }
     /** @var quipThread $thread */
     $this->thread = $this->modx->getObject('quipThread', array('name' => $threadName));
     if (!$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();
         $this->thread->sync($this->getProperties());
     }
     if ($this->thread) {
         $closeAfter = (int) $this->getProperty('closeAfter', 14, 'isset');
         $open = $this->thread->checkIfStillOpen($closeAfter) && !$this->getProperty('closed', false, 'isset');
         $this->setProperty('stillOpen', $open);
     }
     return $this->thread;
 }