コード例 #1
0
ファイル: contentbase.php プロジェクト: k-kalashnikov/forKoda
 /**
  * Если для даннго типа контета существует свой именованный маршрут,
  * возвращает его имя. Иначе вовзращает имя стандартного маршрута.
  * @return string Alias маршрута
  */
 function getNamedRoute()
 {
     $routes = \Base::instance()->get('ALIASES');
     if (isset($routes['frontend_' . $this->table . '_node'])) {
         return 'frontend_' . $this->table . '_node';
     } else {
         return 'frontend_content_node';
     }
 }
コード例 #2
0
ファイル: group.php プロジェクト: k-kalashnikov/forKoda
 /**
  * Формирует список нодов и устанавливает необходимые переменные
  * @param type $this->fw
  * */
 protected function setList()
 {
     $this->setListPage();
     $list = $this->model->getList($this->list_page - 1, $this->list_perpage, true, null, $filter);
     foreach ($list['subset'] as $k => $item) {
         $list['subset'][$k]['title'] = stripslashes($item['name']);
     }
     //		\helpers\Debug::prePrintR($list);
     $list['pages'] = \models\Base::getPaginationPages($list['count'], $list['pos']);
     $list['is_sortable'] = true;
     $this->fw->mset(array('list' => $list, 'tpl' => 'group', 'inc' => 'ajax/list.html', 'pagination_route' => 'backend_group_page'));
     $this->setAJAXFields();
     // Необходимо для корректной генерации полей в модальных окнах для быстрого редактирования
 }
コード例 #3
0
ファイル: _.php プロジェクト: WilliamStam/Directory
 public static function dbStructure($table, $additionalFields = array())
 {
     $f3 = \Base::instance();
     $result = array();
     foreach ($f3->get("DB")->exec("EXPLAIN {$table};") as $key => $value) {
         $result[$value["Field"]] = "";
     }
     foreach ($additionalFields as $key => $value) {
         if ($key) {
             $result[$key] = $value;
         } else {
             $result[$value] = "";
         }
     }
     return $result;
 }
コード例 #4
0
ファイル: Category.php プロジェクト: archlicher/PHP_Project
 public function __construct()
 {
     parent::__construct(array('table' => 'categories'));
 }
コード例 #5
0
ファイル: acl.php プロジェクト: k-kalashnikov/forKoda
 /**
  * Меняет значение поля для правила
  * @param type $post
  * @return boolean
  */
 public function update($post)
 {
     $post = $this->isValid($post);
     //		\helpers\Debug::prePrintR($post);
     //	var_dump($post);
     if ($post !== false) {
         $changed = false;
         $node = $this->load($post['id']);
         // Основные поля
         $fields = array('group_id', 'object', 'relation', 'actions', 'active');
         foreach ($fields as $f) {
             if (isset($post[$f])) {
                 $node->{$f} = $post[$f];
                 $changed = true;
             }
         }
         $node->save();
         return $changed;
     } else {
         \Base::instance()->error(406);
         return false;
     }
 }
コード例 #6
0
ファイル: usergroup.php プロジェクト: k-kalashnikov/forKoda
 public function moveAllUsers($from, $to = null)
 {
     if (!$to) {
         $to = \Base::Instance()->get('account.default_group_id');
     }
     if (!$this->load($to)) {
         return false;
     }
     $f = $this->db->exec('update _user set group_id=:to where group_id = :from', [':to' => $to, ':from' => $from]);
     return !($f === FALSE);
 }
コード例 #7
0
ファイル: Order.php プロジェクト: archlicher/PHP_Project
 public function __construct()
 {
     parent::__construct(array('table' => 'orders'));
 }
コード例 #8
0
ファイル: content.php プロジェクト: k-kalashnikov/forKoda
 /**
  * Формирует список нодов и устанавливает необходимые переменные
  * */
 protected function setList()
 {
     if (!$this->tableMeta->isSortable()) {
         $this->setListPage();
     }
     if (is_null($this->list_filter)) {
         $idsOwners = $this->getAccessibleOwners(\models\ACL::ACTION_READ);
         if (!$idsOwners) {
             \helpers\Msg::warning('read_no_rights');
             $this->fw->error(401);
         }
         if (is_array($idsOwners) && !$this->tableMeta->isTree()) {
             $this->list_filter = [['field' => $this->table . '.user_id', 'value' => $idsOwners, 'operation' => 'IN']];
             //				\helpers\Debug::prePrintR($this->list_filter);
         }
     }
     //		if (!is_null($this->depend_id)) {
     //			$filter[] = [
     //				'field' => 'po_' . $this->meta['depend'],
     //				'value' => $this->depend_id
     //			];
     //		}
     if ($this->tableMeta->isTree()) {
         $this->list_filter[] = ['field' => 'pid', 'value' => $this->pid];
     }
     $list_model = \models\ContentList::getInstance($this->table);
     $filter = new \helpers\filters\FilterRenderer($this->table);
     $list = $list_model->get($this->list_page - 1, $this->list_perpage, true, $this->list_sort, $this->list_filter, $filter->getSQL());
     //		\helpers\Debug::prePrintR($list);
     foreach ($list['subset'] as $k => $item) {
         $list['subset'][$k]['title'] = stripslashes($item['title']);
         //			foreach ($this->dependants as $dependant) {
         //				$res = $this->fw->get('db')
         //						->exec('SELECT count(*) AS cnt '
         //						. 'FROM ' . $dependant . ' '
         //						. 'WHERE fko_' . $this->table . '=?', $item['id']);
         ////						\helpers\Debug::prePrintR($res);
         //				$list['subset'][$k]['dependants'][$dependant] = [
         //					'title' => \models\ContentMeta::decodeInfo($this->meta_all[$dependant]['info'])['title'],
         //					'count' => $res[0]['cnt']
         //				];
         //			}
     }
     //		\helpers\Debug::prePrintR($list);
     $this->setAJAXFields();
     // Необходимо для корректной генерации полей в модальных окнах для быстрого редактирования
     // Ставим флажок, надо ли подключать скрипты для работы со списками объектов,
     // хранящихся в виде дерева
     $list['has_related_tree'] = $this->hasRelatedTree();
     $list['is_sortable'] = $this->tableMeta->isSortable();
     $list['is_tree'] = $this->tableMeta->isTree();
     $list['pid'] = $this->pid;
     $list['pages'] = \models\Base::getPaginationPages($list['count'], $list['pos']);
     $list['is_moderated'] = $this->tableMeta->isModerated();
     if ($this->tableMeta->isModerated()) {
         $this->fw->set('labels.is_moderator', $this->checkAccess(\models\ACL::ACTION_MODERATION));
     }
     $this->fw->mset(array('list' => $list, 'tpl' => 'content', 'inc' => 'ajax/list.html'));
     if ($this->fw->get('use_app_routes')) {
         $this->fw->mset(['pagination_first' => 'app_backend_content', 'pagination_route' => 'app_backend_content_page']);
     } else {
         $this->fw->mset(['pagination_first' => 'backend_content', 'pagination_route' => 'backend_content_page']);
     }
 }
コード例 #9
0
ファイル: Acl.php プロジェクト: RiKap/ErrorMonitoring
 /**
  * Adds unexisting resource to db
  * @param string $resource
  * @return \Nette\Database\Table\ActiveRow
  */
 private function addResourceToDb($resource)
 {
     return $this->lstAclResource->insertIgnore(array("name" => $resource, "ins_dt" => new \DateTime(), "ins_process_id" => 'HQ\\Acl::isAllowed()'));
 }
コード例 #10
0
ファイル: userlist.php プロジェクト: k-kalashnikov/forKoda
 public static function getInstance($table = '_user')
 {
     return parent::getInstance($table);
 }
コード例 #11
0
ファイル: comments.php プロジェクト: k-kalashnikov/forKoda
 public function getList()
 {
     //		\helpers\Debug::prePrintR($this->objects);
     $this->fw->mset(array('html.head_title' => $this->fw->get('i18n.user.menu.comments.moderation'), 'html.page_title' => $this->fw->get('i18n.user.menu.comments.moderation')));
     //$this->fw->set('breadcrumbs.base', '/account');
     $this->fw->set('breadcrumbs.path', array('/account/settings/comments' => $this->fw->get('i18n.user.menu.comments.title')));
     $this->fw->set('breadcrumbs.active', $this->fw->get('i18n.user.menu.comments.moderation'));
     $tmp = array();
     foreach ($this->objects as $table) {
         $tmp[$table->get('table')] = $table->get('comment');
     }
     if ($this->fw->exists('PARAMS.tables')) {
         $tables = explode(',', $this->fw->get('PARAMS.tables'));
     } else {
         $tables = [];
     }
     $this->fw->set('list.filter_sel.object', $tables);
     $this->fw->set('list.filter.object', $tmp);
     $valid_moderation_values = $this->fw->get('i18n.moderation');
     $this->fw->set('list.filter.moderation', $valid_moderation_values);
     $this->fw->set('list.filter_sel.moderation', []);
     if ($this->fw->exists('PARAMS.moderation')) {
         $params = explode(',', $this->fw->get('PARAMS.moderation'));
         $tmp = array_keys($valid_moderation_values);
         foreach ($params as $v) {
             if (in_array($v, $tmp)) {
                 $this->fw->push('list.filter_sel.moderation', $v);
             }
         }
     }
     if ($this->fw->get('list.filter_sel.moderation')) {
         $filter = ' WHERE `moderation` IN ("' . implode('","', $this->fw->get('list.filter_sel.moderation')) . '")';
     } else {
         $filter = '';
     }
     $queries = array();
     foreach ($this->objects as $table) {
         if (empty($tables) || in_array($table->get('table'), $tables)) {
             $queries[] = 'SELECT "' . $table->get('table') . '" AS `obj_slug`, `comments_' . $table->get('table') . '`.* FROM `comments_' . $table->get('table') . '`' . $filter;
         }
     }
     $this->setListPage();
     $q = implode(' UNION ', $queries);
     //		\helpers\Debug::prePrintR($q);
     $this->db->exec($q);
     $this->fw->set('list.count', ceil($this->db->count() / $this->fw->get('account.perpage')));
     // Кол-во страниц
     $this->fw->set('list.pos', $this->list_page - 1);
     // Текущая страница
     $this->fw->set('list.pages', \models\Base::getPaginationPages($this->fw->get('list.count'), $this->fw->get('list.pos')));
     //		\helpers\Debug::prePrintR($this->fw->get('list.count'));
     $q .= ' ORDER BY `created` DESC LIMIT ' . ($this->list_page - 1) * $this->fw->get('account.perpage') . ',' . $this->fw->get('account.perpage');
     //		\helpers\Debug::prePrintR($q);
     $list = $this->db->exec($q);
     //		\helpers\Debug::prePrintR($list);
     //		$list = $this->model->getListAll($this->list_page);
     //			\helpers\Debug::prePrintR($list);
     $this->fw->set('list.subset', $list);
     $this->fw->set('list.is_sortable', false);
     $this->fw->set('tpl', 'comments');
     $this->fw->set('inc', 'comments/list.html');
 }
コード例 #12
0
ファイル: Product.php プロジェクト: archlicher/PHP_Project
 public function __construct()
 {
     parent::__construct(array('table' => 'products'));
 }
コード例 #13
0
ファイル: contentlist.php プロジェクト: k-kalashnikov/forKoda
 /**
  * Составляет список полей, доступных для сортировки
  * @param string $table таблица
  * @param boolean $for_admin для админа
  * @return array список названий полей
  */
 static function getSortFieldNameList($table, $for_admin = false)
 {
     $cached_var = 'cached.sort_field_name_list.' . $table;
     $cache = \Cache::instance();
     if (!$cache->exists($cached_var, $list)) {
         $list = array('title', 'created', 'published', 'slug', 'priority');
         if ($for_admin) {
             $list[] = 'moderation';
             $list[] = 'deleted';
             $list[] = 'edited';
         }
         $tableMeta = \models\meta\Meta::getInstance()->getTableMeta($table);
         foreach ($tableMeta->getFields() as $k => $v) {
             if (preg_match('/^af_(.+)$/', $v['Field'], $m)) {
                 $list[] = $v['Field'];
             }
             if (preg_match('/^fko_(.+)$/', $v['Field'], $m)) {
                 $list[] = 'po_' . $m[1];
             }
         }
         \Base::instance()->set($cached_var, $list, 60 * 60 * 24);
     }
     foreach ($list as $v) {
         $list2[] = $table . '.' . $v;
     }
     return array_merge($list, $list2);
 }
コード例 #14
0
ファイル: content.php プロジェクト: k-kalashnikov/forKoda
 /**
  * Формирует массив, используемый для последующей генерации кода для
  * AJAX-редактирования и добавления записей в БД
  * @param string $table
  * @return array Массив с параметрами ajax-переменных
  */
 static function getAjaxAdditionalFields($table)
 {
     $ajax_fields = [];
     $tableMeta = \models\meta\Meta::getInstance()->getTableMeta($table);
     foreach ($tableMeta->getAdditionalFields() as $v) {
         //$type = self::getInputType($v['type']);
         if ($v['input_type'] == 'wysiwyg') {
             // Если есть поле с виз.редактором, подключаем его
             \Base::instance()->set('WYSIWYG.show', true);
         }
         $ajax_fields['af_' . $v['name']] = array('type' => $v['input_type'], 'name' => 'af_' . $v['name'], 'placeHolder' => $v['comment'], 'label' => $v['title']);
     }
     return $ajax_fields;
 }
コード例 #15
0
ファイル: user.php プロジェクト: k-kalashnikov/forKoda
 private function isValid($post, $oneField = false)
 {
     $f3 = \Base::instance();
     $audit = \Audit::instance();
     if (isset($post['email']) && isset($post['password']) || $oneField) {
         $isValid = true;
         foreach ($post as $name => $val) {
             switch (trim($name)) {
                 case 'email':
                     if (empty($val)) {
                         \helpers\Msg::error('user.email.required');
                         $isValid = false;
                         break 2;
                     }
                     if (!$audit->email($val, false)) {
                         \helpers\Msg::error('user.email.incorrect');
                         $isValid = false;
                         break 2;
                     }
                     if ($this->exists($val)) {
                         \helpers\Msg::error('user.email.registered_before');
                         \helpers\Msg::info('user.need_to_login');
                         $isValid = false;
                         break 2;
                     }
                     break;
                 case 'password':
                     if (strlen($val) < 6) {
                         \helpers\Msg::error('user.password.too_short');
                         $isValid = false;
                         break 2;
                     }
                     break;
                     //					case 'skype' :
                     //						if (!empty($val) && !preg_match('/^[a-z][a-z0-9\.,\-_]{5,31}$/i', $val)) {
                     //							\helpers\Msg::error('user.skype.incorrect');
                     //							$isValid = false;
                     //							break 2;
                     //						}
                     //						break;
                 //					case 'skype' :
                 //						if (!empty($val) && !preg_match('/^[a-z][a-z0-9\.,\-_]{5,31}$/i', $val)) {
                 //							\helpers\Msg::error('user.skype.incorrect');
                 //							$isValid = false;
                 //							break 2;
                 //						}
                 //						break;
                 case 'ref':
                     $val = (int) $val;
                     if ($val == 0) {
                         break 2;
                     } else {
                         //								\helpers\Debug::prePrintR($val);
                         $user = $this->getOne($val);
                         //								\helpers\Debug::prePrintR($user);
                         if ($user->id != $val) {
                             \helpers\Msg::error('user.ref.incorrect');
                             $isValid = false;
                             break 2;
                         }
                     }
                     break;
             }
         }
     } else {
         if (!isset($post['email'])) {
             \helpers\Msg::error('user.email.required');
         }
         if (!isset($post['password'])) {
             \helpers\Msg::error('user.password.required');
         }
         $isValid = false;
     }
     return $isValid;
 }