Example #1
0
 /**
  * Some JodelJodel bindings
  * 
  * @access public
  */
 function beforeFilter()
 {
     parent::beforeFilter();
     App::Import('Behavior', 'Status.Status');
     //starts all status with nothing active
     StatusBehavior::setGlobalActiveStatuses(array('publishing_status' => array('active' => array(), 'overwrite' => true, 'mergeWithCurrentActiveStatuses' => false)));
     // in the applicationAppController or in each controller of a plugin (in beforeRender) is need to add the status, like this
     /*
     	StatusBehavior::setGlobalActiveStatuses(array(
     		'publishing_status' => array('active' => array('published'), 'overwrite' => true, 'mergeWithCurrentActiveStatuses' => false),
     	));
     */
     $curModule = array();
     if ($this->params['plugin']) {
         $curModule = Configure::read('jj.modules.' . $this->params['plugin']);
         if (empty($curModule)) {
             $module = split('_', $this->params['plugin']);
             if (isset($module[1])) {
                 $curModule = Configure::read('jj.modules.' . $module[1]);
             }
             if (empty($curModule)) {
                 if (isset($module[1])) {
                     $curModule = Configure::read('jj.modules.' . Inflector::singularize($module[1]));
                 }
             }
         }
     }
     if (!empty($curModule)) {
         list($plugin, $model) = pluginSplit($curModule['model']);
         if (!isset($curModule['viewUrl'])) {
             $curModule['viewUrl'] = array();
         }
         if (!is_array($curModule['viewUrl'])) {
             trigger_error('BackstageTypeBricklayerHelper::moduleView() - `viewUrl` configuration must be an array.');
             return false;
         }
         $plugin = Inflector::underscore($plugin);
         $standardUrl = $curModule['viewUrl'] + array('plugin' => $plugin, 'controller' => Inflector::pluralize($plugin), 'action' => 'view');
     } else {
         $standardUrl = array('controller' => 'controller', 'action' => 'view');
     }
     if ($this->params['action'] == $standardUrl['action'] && $this->params['controller'] == $standardUrl['controller']) {
         if ($this->JjAuth->can('view_drafts')) {
             //if the user have the permission view_drafts then the status are changed to published and draft
             StatusBehavior::setGlobalActiveStatuses(array('publishing_status' => array('active' => array('published', 'draft'), 'overwrite' => true, 'mergeWithCurrentActiveStatuses' => true)));
         }
     }
 }
 /**
  * beforeFilter callback
  * For while, it allows everyone to have access even if AuthComponent is set.
  * 
  * @access public
  * @todo Better user filtering
  */
 public function beforeFilter()
 {
     parent::beforeFilter();
     $this->JjAuth->allow('*');
     StatusBehavior::setGlobalActiveStatuses(array('publishing_status' => array('active' => array('published', 'draft'), 'overwrite' => false)));
 }
 function testFindAfterSetGlobalActiveStatusWithDifferentStatusSetGlobalAndLocal()
 {
     StatusBehavior::setGlobalActiveStatuses(array('etapa' => array('active' => array('verde', 'maduro'), 'overwrite' => false)));
     $this->StaProduto =& ClassRegistry::init('StaProduto');
     $result = $this->StaProduto->setActiveStatuses(array('etapa' => array('verde')));
     if (!$result) {
         $this->assertEqual(true, false);
     } else {
         $this->assertEqual(true, true);
     }
 }
 /**
  * Used to overwrite any configuration of StatusBehavior.
  * 
  * @access public
  */
 function beforeFilter()
 {
     parent::beforeFilter();
     StatusBehavior::setGlobalActiveStatuses(array('publishing_status' => array('active' => array('published', 'draft'), 'overwrite' => true, 'mergeWithCurrentActiveStatuses' => false)));
 }