/**
  * Returns related modElement instances based on the element_class column.
  *
  * {@inheritdoc}
  */
 public function &getOne($alias, $criteria = null, $cacheFlag = true)
 {
     if ($alias == 'Element') {
         $criteria = $this->xpdo->newQuery($this->get('element_class'), $criteria);
     }
     $object = parent::getOne($alias, $criteria, $cacheFlag);
     return $object;
 }
예제 #2
0
 function prepareRow(xPDOObject $object)
 {
     /** @var byAd $ad */
     $ad = $object->getOne('Ad');
     $row = array_merge($ad->toArray(), $object->toArray());
     $row['image'] = $ad->getImageUrl();
     return $row;
 }
예제 #3
0
 /** @inheritdoc} */
 public function sendNotice(xPDOObject $instance, $status = 0)
 {
     $this->modx->log(1, print_r('sendNotice sendNotice', 1));
     if (!$status) {
         $status = $instance->getOne('Status');
     } else {
         $status = $this->modx->getObject('MlmSystemStatus', $status);
     }
     if (!$status or !$this->MlmSystem->getOption('mail_notice', null, false)) {
         return false;
     }
     /* get context */
     if (!($context = $instance->get('context'))) {
         $context = !$this->modx->context->key || $this->modx->context->key == 'mgr' ? 'web' : $this->modx->context->key;
     }
     /* get users */
     $user = array();
     switch (true) {
         case $instance instanceof MlmSystemClient:
             $user[] = $instance->get('id');
             break;
         default:
             break;
     }
     $pls = array('listUser' => '', 'listEmail' => '', 'subjectEmail' => '', 'bodyEmail' => '', 'queueEmail' => false, 'getUser' => false, 'formatField' => true, 'fastMode' => true, 'context' => $context, 'addPls' => array());
     if ($status->get('email_user')) {
         if ($chunk = $this->modx->getObject('modChunk', $status->get('tpl_user'))) {
             $plsWork = $pls;
             $plsWork['listUser'] = implode(',', $user);
             if ($properties = $chunk->getProperties()) {
                 foreach ($properties as $k => $v) {
                     if (!isset($plsWork[$k])) {
                         $plsWork[$k] = $v;
                     } elseif (is_string($plsWork[$k]) and !empty($plsWork[$k])) {
                         $plsWork[$k] .= ',' . $v;
                     } elseif (is_string($plsWork[$k]) and empty($plsWork[$k])) {
                         $plsWork[$k] = $v;
                     } elseif (is_array($plsWork[$k])) {
                         $plsWork[$k] = array_merge($this->modx->fromJSON($v), $plsWork[$k]);
                     } elseif (is_bool($plsWork[$k])) {
                         $plsWork[$k] = $v;
                     }
                 }
             }
             $plsWork['addPls'] = array_merge($plsWork['addPls'], $this->processObject($instance, (int) $plsWork['formatField']));
             $this->runProcessor('mgr/email/send', $plsWork);
         }
     }
     if ($status->get('email_manager')) {
         if ($chunk = $this->modx->getObject('modChunk', $status->get('tpl_manager'))) {
             $plsWork = $pls;
             $plsWork['listEmail'] = $this->MlmSystem->getOption('email_manager', null, $this->modx->getOption('emailsender'));
             if ($properties = $chunk->getProperties()) {
                 foreach ($properties as $k => $v) {
                     if (!isset($plsWork[$k])) {
                         $plsWork[$k] = $v;
                     } elseif (is_string($plsWork[$k]) and !empty($plsWork[$k])) {
                         $plsWork[$k] .= ',' . $v;
                     } elseif (is_string($plsWork[$k]) and empty($plsWork[$k])) {
                         $plsWork[$k] = $v;
                     } elseif (is_array($plsWork[$k])) {
                         $plsWork[$k] = array_merge($this->modx->fromJSON($v), $plsWork[$k]);
                     } elseif (is_bool($plsWork[$k])) {
                         $plsWork[$k] = $v;
                     }
                 }
             }
             $plsWork['addPls'] = array_merge($plsWork['addPls'], $this->processObject($instance, (int) $plsWork['formatField']));
             $this->runProcessor('mgr/email/send', $plsWork);
         }
     }
     return true;
 }