예제 #1
0
 public static function install(array $options = array())
 {
     $toret = parent::install($options);
     $toret = Hook::add('update', 'post', __CLASS__, array('global' => true, 'description' => 'Create the following revision of a post after the content has been updated.')) && $toret;
     $toret = Hook::add('create', 'post', __CLASS__, array('global' => true, 'description' => 'Add the first revision of the content after the content has been created.')) && $toret;
     return $toret;
 }
예제 #2
0
 public static function install(array $options = array())
 {
     $toret = parent::install($options);
     $toret = Hook::add('output', 'pre', get_called_class(), array('global' => 1)) && $toret;
     $toret = Permission::add('anonymous', 'add', get_called_class()) && $toret;
     $toret = Permission::add('authenticated', 'add', get_called_class()) && $toret;
     return $toret;
 }
예제 #3
0
 public static function install(array $options = array())
 {
     $options['drop_table'] = array_key_exists('drop_table', $options) ? $options['drop_table'] : true;
     $toret = parent::install($options);
     foreach (self::getDefaults() as $role) {
         $toret = self::add($role['name'], $role['description'], array('id' => $role['id'], 'active' => $role['active'])) && $toret;
     }
     return $toret;
 }
예제 #4
0
 public static function doIndex(TableCtl $controller, $fields = array('content'))
 {
     if (!is_array($fields)) {
         $fields = array($fields);
     }
     //TODO This is a bad idea. rather use a query and while
     $object = $controller->get_list('all', 0);
     $total = false;
     if ($object->list) {
         $total = 0;
         $first = current($object->list);
         foreach ($fields as $field) {
             if (array_key_exists($field, $first)) {
                 $result = 0;
                 foreach ($object->list as $row) {
                     $info = str_word_count($row[$field], 1);
                     $counts = array_count_values($info);
                     $sequence = 0;
                     foreach ($counts as $word => $count) {
                         unset($counts[$word]);
                         if ($word = self::filter($word, $count)) {
                             $data = array('table' => $object->getSource(), 'table_id' => $row[$object->getMeta('id_field')], 'word' => $word, 'count' => $count, 'sequence' => $sequence++);
                             $b_search = new BackendSearchObj();
                             if ($b_search->replace($data)) {
                                 $result++;
                                 $total++;
                             } else {
                                 if ($b_search->error_msg != 'Error executing statement(1062)') {
                                     Backend::addError('Could not add ' . $word . ' to ' . get_class($controller) . '::' . $field . ' index');
                                 }
                             }
                         }
                     }
                 }
                 if ($result > 0) {
                     Backend::addSuccess($result . ' words were indexed for ' . get_class($controller) . '::' . $field);
                 }
             } else {
                 Backend::addError($field . ' does not exist in ' . get_class($object));
             }
         }
     }
     return $total;
 }
예제 #5
0
 public static function install(array $options = array())
 {
     $options['drop_table'] = array_key_exists('drop_table', $options) ? $options['drop_table'] : true;
     $toret = parent::install($options);
     foreach (self::getDefaults() as $assignment) {
         if (GateKeeper::assign($assignment['role'], $assignment['access_type'], $assignment['access_id'])) {
             Backend::addSuccess('Added assignment to ' . $assignment['role']);
             $toret = $toret && true;
         } else {
             Backend::addError('Could not add assignment to ' . $assignment['role']);
             $toret = false;
         }
     }
     return $toret;
 }
예제 #6
0
 public function html_display($result)
 {
     $result = parent::html_display($result);
     if (Value::get(get_class($this) . '_commented', true) && Component::isActive('Comment')) {
         if ($result instanceof DBObject) {
             $comments = Comment::getComments($result->getMeta('table'), $result->getMeta('id'));
             Backend::addContent(Render::renderFile('comments.tpl.php', array('comment_list' => $comments)));
             if (Permission::check('create', 'comment')) {
                 $values = array('foreign_table' => $result->getMeta('table'), 'foreign_id' => $result->getMeta('id'));
                 Backend::addContent(Render::renderFile('comment.add.tpl.php', $values));
             }
         }
     }
     return $result;
 }
예제 #7
0
 public static function install(array $options = array())
 {
     $toret = parent::install($options);
     $toret = Hook::add('start', 'pre', __CLASS__, array('global' => true, 'sequence' => 1000)) && $toret;
     return $toret;
 }
예제 #8
0
 public static function install(array $options = array())
 {
     $toret = parent::install($options);
     Hook::add('init', 'pre', get_called_class()) && $toret;
     return $toret;
 }
예제 #9
0
 public static function install(array $options = array())
 {
     $options['install_model'] = array_key_exists('install_model', $options) ? $options['install_model'] : false;
     $toret = parent::install($options);
     foreach (self::getDefaults() as $permit) {
         GateKeeper::permit($permit['role'], $permit['action'], $permit['subject'], $permit['subject_id'], $permit['control']);
         if (Controller::$debug) {
             Backend::addSuccess('Added permission to ' . $permit['action'] . ' to ' . $permit['role']);
         }
     }
     return $toret;
 }
예제 #10
0
 public static function install(array $options = array())
 {
     $toret = parent::install($options);
     $toret = Hook::add('update', 'post', get_called_class(), array('description' => 'Check for enabled / requested themes, and change the view name accordingly.')) && $toret;
     return $toret;
 }
예제 #11
0
 /**
  * Read defaults to dbobject, as we need to get mime types, etc.
  */
 public function action_read($id, $mode = 'dbobject')
 {
     $result = parent::action_read($id, $mode);
     return $result;
 }
예제 #12
0
 public static function install(array $options = array())
 {
     $options['drop_table'] = array_key_exists('drop_table', $options) ? $options['drop_table'] : true;
     $options['install_model'] = array_key_exists('install_model', $options) ? $options['install_model'] : false;
     $toret = parent::install($options);
     return $toret;
 }
예제 #13
0
 public static function install(array $options = array())
 {
     $options['install_model'] = array_key_exists('install_model', $options) ? $options['install_model'] : false;
     $result = parent::install($options);
     if (!Backend::getDB('default')) {
         return $result;
     }
     Hook::add('init', 'pre', get_called_class()) && $result;
     return $result;
 }
예제 #14
0
 public static function install(array $options = array())
 {
     $toret = parent::install($options);
     return $toret;
 }
예제 #15
0
 public static function install(array $options = array())
 {
     $options['install_model'] = array_key_exists('install_model', $options) ? $options['install_model'] : true;
     $result = parent::install($options);
     if (!Backend::getDB('default')) {
         return $result;
     }
     $result = Hook::add('init', 'post', get_called_class(), array('global' => true, 'sequence' => 0)) && $result;
     $result = Hook::add('start', 'pre', get_called_class(), array('global' => true)) && $result;
     $result = Hook::add('finish', 'post', get_called_class(), array('global' => true)) && $result;
     $result = Permission::add('anonymous', 'super_signup', get_called_class()) && $result;
     $result = Permission::add('anonymous', 'signup', get_called_class()) && $result;
     $result = Permission::add('anonymous', 'confirm', get_called_class()) && $result;
     $result = Permission::add('anonymous', 'login', get_called_class()) && $result;
     $result = Permission::add('authenticated', 'login', get_called_class()) && $result;
     $result = Permission::add('authenticated', 'logout', get_called_class()) && $result;
     $result = Permission::add('authenticated', 'display', get_called_class()) && $result;
     $result = Permission::add('authenticated', 'update', get_called_class()) && $result;
     $result = Permission::add('authenticated', 'change_password', get_called_class()) && $result;
     return $result;
 }
예제 #16
0
 public static function install(array $options = array())
 {
     $toret = parent::install($options);
     $toret = Permission::add('anonymous', 'display', get_called_class()) && $toret;
     $toret = Permission::add('authenticated', 'display', get_called_class()) && $toret;
     $toret = Permission::add('anonymous', 'list', get_called_class()) && $toret;
     $toret = Permission::add('authenticated', 'list', get_called_class()) && $toret;
     $toret = Hook::add('table_display', 'post', get_called_class(), array('global' => 1)) && $toret;
     $toret = Hook::add('table_update', 'pre', get_called_class(), array('global' => 1)) && $toret;
     $toret = Hook::add('table_update', 'post', get_called_class(), array('global' => 1)) && $toret;
     $toret = Hook::add('table_create', 'post', get_called_class(), array('global' => 1)) && $toret;
     return $toret;
 }
예제 #17
0
 function action_read($file, $mode = 'array')
 {
     $file = urldecode($file);
     return parent::action_read($file, $mode);
 }