Ejemplo n.º 1
0
 /**
  * Constructor
  * Loads points configuration
  *
  * @return  object
  */
 public static function values()
 {
     $pc = self::all()->rows();
     $config = new Object();
     foreach ($pc as $p) {
         $config->set($p->get('alias'), $p->get('points'));
     }
     return $config;
 }
Ejemplo n.º 2
0
 /**
  * Gets a list of the actions that can be performed.
  *
  * @return  object  Object
  */
 public static function getActions()
 {
     $assetName = self::$extension;
     $actions = \JAccess::getActions($assetName);
     $result = new Object();
     foreach ($actions as $action) {
         $result->set($action->name, User::authorise($action->name, $assetName));
     }
     return $result;
 }
Ejemplo n.º 3
0
 /**
  * Gets a list of the actions that can be performed.
  *
  * @param   string   $extension  The extension.
  * @param   integer  $assetId    The asset ID.
  * @return  object   Object
  */
 public static function getActions($assetType = 'component', $assetId = 0)
 {
     $assetName = self::$extension;
     if ($assetId) {
         $assetName .= '.' . (int) $assetId;
     }
     $result = new Object();
     $actions = array('core.admin', 'core.manage', 'core.create', 'core.edit', 'core.edit.state', 'core.delete');
     foreach ($actions as $action) {
         $result->set($action, User::authorise($action, $assetName));
     }
     return $result;
 }
Ejemplo n.º 4
0
 /**
  * Gets a list of the actions that can be performed.
  *
  * @param   string   $extension  The extension.
  * @param   integer  $assetId    The category ID.
  * @return  object
  */
 public static function getActions($assetType = 'component', $assetId = 0)
 {
     $assetName = self::$extension;
     $assetName .= '.' . $assetType;
     if ($assetId) {
         $assetName .= '.' . (int) $assetId;
     }
     $user = \User::getInstance();
     $result = new Object();
     $actions = array('admin', 'manage', 'create', 'edit', 'edit.state', 'delete');
     foreach ($actions as $action) {
         $result->set('core.' . $action, $user->authorise('core.' . $action, $assetName));
     }
     return $result;
 }
Ejemplo n.º 5
0
 /**
  * Constructs the class
  *
  * @param   mixed  $properties  Either and associative array or another
  *                              object to set the initial properties of the object.
  */
 public function __construct($properties = null)
 {
     parent::__construct($properties);
     if (func_num_args() == 2) {
         $this->setAdapter(func_get_arg(1));
     }
 }
Ejemplo n.º 6
0
 /**
  * Class constructor
  *
  * @param   array  $options  An array of configuration options.
  * @return  void
  */
 public function __construct($options = array())
 {
     parent::__construct($options);
     // Load the menu items
     $this->load();
     foreach ($this->_items as $item) {
         if ($item->home) {
             $this->_default[trim($item->language)] = $item->id;
         }
         // Decode the item params
         $item->params = new Registry($item->params);
     }
 }
Ejemplo n.º 7
0
 /**
  * Constructor
  *
  * @param   array  $config  An array of configuration options
  * @return  void
  */
 public function __construct($config = array())
 {
     parent::__construct();
     // Set the model state
     if (array_key_exists('state', $config)) {
         $this->state = $config['state'];
     } else {
         $this->state = new Object();
     }
     // Set the model dbo
     if (array_key_exists('dbo', $config)) {
         $this->db = $config['dbo'];
     } else {
         $this->db = App::get('db');
     }
     // Set the internal state marker - used to ignore setting state from the request
     if (!empty($config['ignore_request'])) {
         $this->__state_set = true;
     }
 }
Ejemplo n.º 8
0
 /**
  * Add an error message.
  *
  * @param   string  $error  Error message.
  * @param   string  $key    Specific key to set the value to
  * @return  object
  */
 public function setError($error, $key = null)
 {
     $bt = debug_backtrace();
     $error = __CLASS__ . '::' . $bt[1]['function'] . '():' . $error;
     return parent::setError($error, $key);
 }
Ejemplo n.º 9
0
 /**
  * Get the allowed actions for an identity.
  *
  * @param   mixed  $identity  An integer representing the identity or an array of identities
  * @return  object  Allowed actions for the identity or identities
  */
 public function getAllowed($identity)
 {
     // Sweep for the allowed actions.
     $allowed = new Object();
     foreach ($this->data as $name => &$action) {
         if ($action->allow($identity)) {
             $allowed->set($name, true);
         }
     }
     return $allowed;
 }
Ejemplo n.º 10
0
 /**
  * Class constructor.
  *
  * @param   array  $options  Associative array of options
  * @return  void
  */
 public function __construct($options = array())
 {
     parent::__construct();
     if (array_key_exists('lineend', $options)) {
         $this->setLineEnd($options['lineend']);
     }
     if (array_key_exists('charset', $options)) {
         $this->setCharset($options['charset']);
     }
     if (array_key_exists('language', $options)) {
         $this->setLanguage($options['language']);
     }
     if (array_key_exists('direction', $options)) {
         $this->setDirection($options['direction']);
     }
     if (array_key_exists('tab', $options)) {
         $this->setTab($options['tab']);
     }
     if (array_key_exists('link', $options)) {
         $this->setLink($options['link']);
     }
     if (array_key_exists('base', $options)) {
         $this->setBase($options['base']);
     }
 }
Ejemplo n.º 11
0
 /**
  * Returns an array of standard published state filter options.
  *
  * @return  object
  */
 public function parseXMLTemplateFile($templateBaseDir, $templateDir)
 {
     $data = new Object();
     // Check of the xml file exists
     $filePath = Filesystem::cleanPath($templateBaseDir . '/templates/' . $templateDir . '/templateDetails.xml');
     if (is_file($filePath)) {
         $xml = \JInstaller::parseXMLInstallFile($filePath);
         if ($xml['type'] != 'template') {
             return false;
         }
         foreach ($xml as $key => $value) {
             $data->set($key, $value);
         }
     }
     return $data;
 }
Ejemplo n.º 12
0
 /**
  * Test setting a default value if not alreay assigned
  *
  * @covers  \Hubzero\Base\Object::def
  * @return  void
  **/
 public function testDef()
 {
     $obj = new Object();
     $obj->def('bar', 'ipsum');
     $this->assertEquals($obj->get('bar'), 'ipsum');
     $obj->set('foo', 'bar');
     $obj->def('foo', 'lorem');
     $this->assertEquals($obj->get('foo'), 'bar');
 }
Ejemplo n.º 13
0
 /**
  * Modifies a property of the object, creating it if it does not already exist.
  *
  * @param   string  $property  The name of the property
  * @param   mixed   $value     The value of the property to set
  * @return  mixed   Previous value of the property
  */
 public function set($property, $value = null)
 {
     if ($property == 'scope') {
         $this->_scope = $value;
         return $this;
     }
     if ($property == 'scope_id') {
         $this->_scope_id = $value;
         return $this;
     }
     return parent::set($property, $value);
 }