Ejemplo n.º 1
0
 /** {@inheritDoc} */
 public function initialize()
 {
     if (!$this->modx->hasPermission($this->permission)) {
         return $this->modx->lexicon('access_denied');
     }
     return parent::initialize();
 }
Ejemplo n.º 2
0
 /**
  * We doing special check of permission
  * because of our objects is not an instances of modAccessibleObject
  *
  * @return mixed
  */
 public function process()
 {
     if (!$this->checkPermissions()) {
         return $this->failure($this->modx->lexicon('access_denied'));
     }
     return parent::process();
 }
Ejemplo n.º 3
0
 public function beforeOutput()
 {
     var_dump($this->object->discount_method);
     die;
     parent::beforeOutput();
     // TODO: Change the autogenerated stub
 }
Ejemplo n.º 4
0
 public function initialize()
 {
     $target = $this->getProperty('target', false);
     if (empty($target)) {
         return $this->modx->lexicon($this->objectType . '_err_ns');
     }
     $primaryKey = $this->getProperty($this->primaryKeyField, false);
     if (empty($primaryKey)) {
         return $this->modx->lexicon($this->objectType . '_err_ns');
     }
     if ($target === $primaryKey) {
         return $this->modx->lexicon('error.link_of_selflink_not_possible');
     }
     $this->targetResource = $this->modx->getObject('modResource', intval($target));
     if (!$this->targetResource) {
         return $this->modx->lexicon('error.invalid_resource_id', array('resource' => $target));
     }
     $contextKey = $this->getProperty('context', false);
     if (empty($contextKey)) {
         return $this->modx->lexicon('babel.context_err_ns');
     }
     $context = $this->modx->getObject('modContext', array('key' => $contextKey));
     if (!$context) {
         return $this->modx->lexicon('error.invalid_context_key', array('context' => $contextKey));
     }
     if ($this->targetResource->get('context_key') !== $contextKey) {
         return $this->modx->lexicon('error.resource_from_other_context', array('resource' => $this->targetResource->get('id'), 'context' => $contextKey));
     }
     return parent::initialize();
 }
Ejemplo n.º 5
0
 /** {@inheritDoc} */
 public function initialize()
 {
     /** @var gl $gl */
     $this->gl = $this->modx->getService('gl');
     $this->gl->initialize($this->getProperty('context', $this->modx->context->key));
     return parent::initialize();
 }
Ejemplo n.º 6
0
 public function beforeOutput()
 {
     if ($this->getProperty('getGroups', false)) {
         $this->getGroups();
     }
     return parent::beforeOutput();
 }
Ejemplo n.º 7
0
 /** {@inheritDoc} */
 public function initialize()
 {
     /** @var mlmsystem $mlmsystem */
     $this->MlmSystem = $this->modx->getService('mlmsystem');
     $this->MlmSystem->initialize($this->getProperty('context', $this->modx->context->key));
     return parent::initialize();
 }
Ejemplo n.º 8
0
 /**
  * Initialize property set
  * @return bool|null|string
  */
 public function initialize()
 {
     $this->default = $this->getDefaultSet();
     $id = $this->getProperty($this->primaryKeyField);
     if ($id == 0) {
         if (empty($this->default)) {
             return $this->modx->lexicon($this->objectType . '_err_nfs', array('id' => $id));
         }
         $this->prepareDefaultSet($this->default);
         return true;
     } else {
         return parent::initialize();
     }
 }
Ejemplo n.º 9
0
 public function initialize()
 {
     if (!($thread_id = (int) $this->getProperty('thread_id'))) {
         /*
             Check required data
         */
         if (!($target_id = (int) $this->getProperty('target_id'))) {
             return "Can not get target ID";
         }
         if (!($target_class = $this->getProperty('target_class', 'modResource'))) {
             return "Can not get target class";
         }
         //else
         /*
             Пытаемся получить ветку диалога по ID цели и классу
         */
         $q = $this->modx->newQuery($this->classKey, array("target_id" => $target_id, "target_class" => $target_class));
         $q->select(array("id"));
         $q->limit(1);
         if (!($s = $q->prepare()) or !$s->execute()) {
             return "Request error";
         }
         //else
         if (!($thread_id = $this->modx->getValue($s))) {
             /*
                 Если не была получена ветка, то пытаемся ее создать
             */
             if (!($response = $this->modx->runProcessor('society/web/threads/create', array("target_id" => $this->getProperty("target_id")), array("processors_path" => dirname(dirname(dirname(dirname(__FILE__)))) . '/')))) {
                 $error = "Ошибка выполнения запроса";
                 $this->modx->log(xPDO::LOG_LEVEL_ERROR, "[- " . __CLASS__ . " -]  {$error}");
                 $this->modx->log(xPDO::LOG_LEVEL_ERROR, "[- " . __CLASS__ . " -] " . print_r($this->getProperties(), true));
                 return $error;
             }
             // else
             if ($response->isError() or !($thread_data = $response->getObject())) {
                 if (!($error = $response->getMessage())) {
                     $error = "Ошибка создания ветви диалога";
                 }
                 $this->modx->log(xPDO::LOG_LEVEL_ERROR, "[- " . __CLASS__ . " -]  {$error}");
                 $this->modx->log(xPDO::LOG_LEVEL_ERROR, "[- " . __CLASS__ . " -] " . print_r($response->getResponse(), true));
                 $this->modx->log(xPDO::LOG_LEVEL_ERROR, "[- " . __CLASS__ . " -] " . print_r($this->getProperties(), true));
                 return $error;
             }
             //else
             $thread_id = $thread_data['id'];
         }
     }
     $this->setProperty('id', $thread_id);
     return parent::initialize();
 }
Ejemplo n.º 10
0
 public function initialize()
 {
     /**
      * Check context
      */
     $this->context = trim($this->getProperty('ctx'));
     if (empty($this->context)) {
         $this->failure($this->modx->lexicon('modxtalks.empty_context'));
         return false;
     } elseif (!$this->modx->getCount('modContext', $this->context)) {
         $this->failure($this->modx->lexicon('modxtalks.bad_context'));
         return false;
     }
     return parent::initialize();
 }
Ejemplo n.º 11
0
 public function initialize()
 {
     if ($this->modx->modxtalks->isModerator()) {
         return parent::initialize();
     }
     $this->context = trim($this->getProperty('ctx'));
     // Check Context
     if (empty($this->context)) {
         $this->failure($this->modx->lexicon('modxtalks.empty_context'));
         return false;
     } elseif (!$this->modx->getCount('modContext', $this->context)) {
         $this->failure($this->modx->lexicon('modxtalks.bad_context'));
         return false;
     }
     if ($this->modx->modxtalks->config['onlyAuthUsers'] && !$this->modx->user->isAuthenticated($this->context)) {
         $this->failure($this->modx->lexicon('modxtalks.no_login'));
         return false;
     }
     return parent::initialize();
     return true;
 }
 /**
  * {@inheritDoc}
  * @return boolean
  */
 public function initialize()
 {
     $this->objectType = $this->getProperty('elementType');
     $this->classKey = 'mod' . ucfirst($this->objectType);
     $this->permission = 'view_' . $this->objectType;
     $tag = $this->getProperty('tag');
     $tagParts = xPDO::escSplit('?', $tag, '`', 2);
     $tagName = trim($tagParts[0]);
     $parser = $this->modx->getParser();
     $elementName = $this->elementName = $parser->realname($tagName);
     if (empty($elementName)) {
         return $this->modx->lexicon($this->objectType . '_err_ns');
     }
     $query = $this->modx->newQuery($this->classKey, array('name' => $elementName));
     $query->select('id');
     $id = $this->modx->getValue($query->prepare());
     if (!$id) {
         return $this->modx->lexicon($this->objectType . '_err_nf');
     }
     $this->setProperty('id', $id);
     return parent::initialize();
 }
Ejemplo n.º 13
0
 public function initialize()
 {
     $this->modx->addPackage('modx.transport', $this->modx->getOption('core_path') . 'model/');
     $this->dateFormat = $this->getProperty('dateFormat', '%b %d, %Y %I:%M %p');
     return parent::initialize();
 }
Ejemplo n.º 14
0
 public function initialize()
 {
     $key = $this->getProperty('key');
     $this->setProperty('key', urldecode($key));
     return parent::initialize();
 }
Ejemplo n.º 15
0
 public function beforeOutput()
 {
     //var_dump($this->object->discount_method); die;
     parent::beforeOutput();
 }
Ejemplo n.º 16
0
 public function initialize()
 {
     $this->modx->addPackage('modx.transport', $this->modx->getOption('core_path') . 'model/');
     $this->dateFormat = $this->getProperty('dateFormat', $this->modx->getOption('manager_date_format') . ', ' . $this->modx->getOption('manager_time_format'));
     return parent::initialize();
 }