Example #1
0
 function getItem($id = NULL)
 {
     $id = $id ? $id : $this->getState('id');
     $this->setState('id', $id);
     $limit = $this->getState('limit') ? ' LIMIT ' . $this->getState('limit') : '';
     $q = $this->getListQuery($this->getStates());
     $item = new struct_core_alias($this->query($q->toString(), $q->getValues()));
     $theme_id = $item->themeid ? $item->themeid : 0;
     $theme2_id = $theme_id;
     if ($item->group_id) {
         $theme2_id = rad_dbpdo::query('SELECT theme_id FROM ' . RAD . 'themes WHERE theme_aliasid=? AND theme_folder=?', array($item->group_id, $item->themefolder));
         $theme2_id = !empty($theme2_id['theme_id']) ? (int) $theme2_id['theme_id'] : $theme_id;
     }
     if ($this->getState('join.aliasgroup')) {
         $table = new model_core_table('aliases');
         $ali_item = $table->getItem($id);
     }
     if (!$this->getState('without_joins')) {
         foreach ($this->queryAll('select params_presonal,inc_id,inc_name,inc_filename,controller,order_sort,rp_name,rp_id,id_module,m_name,ia.id as incinal_id, ia.params_hash as params_hash, 0 as is_ga ' . ($this->getState('join.original_params', false) ? ', ip_params AS original_params ' : '') . 'from ' . RAD . 'includes_in_aliases ia ' . 'inner join ' . RAD . 'includes on include_id=inc_id ' . 'inner join ' . RAD . 'modules m on m.m_id=id_module ' . 'inner join ' . RAD . 'positions p on position_id=p.rp_id ' . ($this->getState('join.original_params', false) ? ' left join ' . RAD . 'includes_params ip ON ip.ip_incid=ia.include_id ' : '') . 'where alias_id=' . $id . ' and ia.theme_id=' . $theme_id . (($this->getState('join.aliasgroup') and isset($ali_item) and $ali_item->group_id) ? ' UNION (' . 'select params_presonal,inc_id,inc_name,inc_filename,controller,order_sort,rp_name,rp_id,id_module,m_name,ia.id as incinal_id, ia.params_hash as params_hash, 1 as is_ga ' . ($this->getState('join.original_params', false) ? ', ip_params AS original_params ' : '') . 'from ' . RAD . 'includes_in_aliases ia ' . 'inner join ' . RAD . 'includes on include_id=inc_id ' . 'inner join ' . RAD . 'modules m on m.m_id=id_module ' . 'inner join ' . RAD . 'positions p on position_id=p.rp_id ' . ($this->getState('join.original_params', false) ? ' left join ' . RAD . 'includes_params ip ON ip.ip_incid=ia.include_id ' : '') . 'where alias_id=' . $ali_item->group_id . ' and ia.theme_id=' . $theme2_id . ')' : '') . ' order by rp_name, order_sort') as $idi) {
             $item->includes[] = new struct_core_include($idi);
             $item->includes[count($item->includes) - 1]->is_ga = (bool) $idi['is_ga'];
         }
     }
     if ($this->getState('join_description')) {
         $wlangid = $this->getState('ald_langid');
         $wlangid = $wlangid ? ' AND ald_langid=' . $wlangid : '';
         foreach ($this->queryAll('SELECT * FROM ' . RAD . 'aliases_description where ald_aliasid=' . $id . $wlangid) as $idd) {
             $item->description[$idd['ald_langid']] = new struct_core_aliases_description($idd);
         }
     }
     return $item;
 }
Example #2
0
 function getItem($id = NULL)
 {
     $id = $id ? $id : $this->getState('id', $this->getState('lng_id', NULL));
     if ($id) {
         $table = new model_core_table('lang');
         return $table->getItem($id);
     } else {
         $this->badRequest(__LINE__);
     }
 }
Example #3
0
 function getItem($id)
 {
     $id = $id ? $id : $this->getState('id');
     if (!$id) {
         $this->badRequest();
     } else {
         $table = new model_core_table('includes_in_aliases');
         if ($this->getState('lang_id')) {
             $table->setState('lnv_id', $id);
         }
         return $table->getItem($id);
     }
 }
Example #4
0
 function __construct()
 {
     if ($this->getParamsObject()) {
         $params = $this->getParamsObject();
         $this->_pid = $params->_get('treestart', $this->_pid, $this->getCurrentLangID());
         $this->showfirstifempty = $params->_get('showfirstifempty', $this->showfirstifempty);
         $this->_isshowpage = $params->_get('isshowpage', $this->_isshowpage);
         $this->_assignRubric = $params->_get('assignrubric', $this->_assignRubric, $this->getCurrentLangID());
         $this->setVar('params', $params);
     }
     if ($this->request('cp') or $this->request('pgid') or $this->_assignRubric) {
         $this->assignPage();
         if ($this->getVar('item')) {
             $this->assignRubrics($this->getVar('item'));
             $this->assignSuRubrics($this->getVar('item'));
         }
     } elseif ($this->request('title')) {
         $this->assignPageByName();
         if ($this->getVar('item')) {
             $this->assignRubrics($this->getVar('item'));
             $this->assignSuRubrics($this->getVar('item'));
         }
     } else {
         $this->assignLanguages();
     }
     if ($this->_isshowpage) {
         $table = new model_core_table('pages', 'corearticles');
         $page = $table->getItem($params->pgid);
         $this->setVar('item', $page);
         $this->addBC('pages', array($page));
     } elseif (!$this->_assignRubric) {
         $this->assignMenu();
         if ($this->showfirstifempty and !($this->request('cp') or $this->request('pgid')) and count($this->getVar('items'))) {
             $model = rad_instances::get('model_corearticles_pages');
             $items = $this->getVar('items');
             if (!empty($items)) {
                 $model->setState('tre_id', $items[0]->tre_id);
                 $pages = $model->getItems(1);
                 $this->setVar('pages', $pages);
                 $this->addBC('pages', $pages);
             }
             //if !empty items
         }
     } else {
         $this->setVar('title', rad_instances::get('model_coremenus_tree')->getItem((int) $this->_assignRubric));
     }
     $this->setVar('page', $this->request('page', 0));
 }
Example #5
0
 function showFullComments()
 {
     if (!$this->request('t', false)) {
         $this->securityHoleAlert(__FILE__, __LINE__, $this->getClassName());
     }
     if (!(int) $this->request('item', false)) {
         $this->securityHoleAlert(__FILE__, __LINE__, $this->getClassName());
     }
     $this->setVar('typ', $this->request('t'));
     //Временная заглушка безопасности
     switch ($this->getVar('typ')) {
         case 'folknews':
         case 'news':
             $tbi = new model_core_table('news', 'corearticles');
             $toItem = $tbi->getItem((int) $this->request('item'));
             $this->setVar('item_title', $toItem->nw_title);
             $this->addBC('item_title', $toItem->nw_title);
             break;
         case 'articles':
             $tbi = new model_core_table('articles', 'corearticles');
             $toItem = $tbi->getItem((int) $this->request('item'));
             $this->setVar('item_title', $toItem->art_title);
             $this->addBC('item_title', $toItem->art_title);
             break;
         case 'product':
             $tbi = new model_core_table('catalog', 'corecatalog');
             $toItem = $tbi->getItem((int) $this->request('item'));
             $this->setVar('item_title', $toItem->cat_name);
             $this->addBC('item_title', $toItem->cat_name);
             break;
         default:
             $this->securityHoleAlert(__FILE__, __LINE__, $this->getClassName());
             break;
     }
     //switch
     $this->setVar('to_item', $toItem);
     $this->setVar('item_id', (int) $this->request('item'));
     $model = rad_instances::get('model_coreresource_comments')->setState('order by', 'rcm_datetime DESC')->setState('item_id', (int) $this->getVar('item_id'))->setState('type', $this->getVar('typ'))->setState('active', 1);
     //GETS THE COUNT
     $model->setState('select', 'count(*)');
     $itemsCount = $model->getItems();
     $model->unsetState('select');
     $limit = $this->_itemsperpage;
     if ((int) $this->request('page')) {
         $limit = ((int) $this->request('page') - 1) * $this->_itemsperpage . ',' . $this->_itemsperpage;
     }
     $this->setVar('items', $model->getItems($limit));
     $gp = 'comments_action=f&t=' . $this->request('t') . '&item=' . (int) $this->request('item') . '';
     $this->setVar('paginator', new rad_paginator(array('total' => $itemsCount, 'itemsperpage' => $this->_itemsperpage, 'getparams' => $gp)));
 }
Example #6
0
 function deleteItem()
 {
     if ($this->request('hash') != $this->hash()) {
         $this->redirect('404');
     }
     if ((int) $this->request('i')) {
         $table = new model_core_table('comments', 'coreresource');
         $item = $table->getItem((int) $this->request('i'));
         if ($item->rcm_id) {
             $table->deleteItem($item);
         }
     } else {
         $this->securityHoleAlert(__FILE__, __LINE__, $this->getClassName());
     }
 }
Example #7
0
 function getItem($id = null)
 {
     $id = $id ? $id : $this->getState('id');
     $table = new model_core_table('langvalues');
     if ($this->getState('lang_id')) {
         $table->setState('lnv_id', $id);
     }
     return $table->getItem($id);
 }
Example #8
0
 /**
  * @param struct_core_users $item
  */
 private function sendActivationCode($item)
 {
     rad_instances::get('model_coremail_subscribes')->removeExpired();
     $table = new model_core_table('subscribers_activationurl', 'coremail');
     $table->setStates(array('sac_scrid' => $item->u_id, 'sac_type' => 2, 'email' => $item->u_email, 'date_confirmed' => 0));
     $item_url = $table->getItem();
     if ($item_url->sac_id) {
         if ($item_url->date_created + 300 > time()) {
             // wow, spam
             return;
         }
         $item_url->date_created = time();
         $table->updateItem($item_url);
     } else {
         $item_url = new struct_coremail_subscribers_activationurl();
         $item_url->sac_url = md5(rad_session::genereCode(31) . now() . $item->u_id);
         $item_url->sac_scrid = $item->u_id;
         $item_url->sac_type = 2;
         $item_url->email = $item->u_email;
         $item_url->date_created = time();
         $table->insertItem($item_url);
     }
     rad_mailtemplate::send($item->u_email, $this->config('activate_email.template'), array('user' => $item, 'link' => $this->makeURL('alias=register&c=' . urlencode($item_url->sac_url)), 'clearpass' => ''), 'html');
 }
Example #9
0
 function addComment()
 {
     if ($this->request('hash') != $this->hash()) {
         return $this->redirect('404');
     }
     $item = new struct_coreresource_comments();
     $item->rcm_datetime = now();
     $item->rcm_type = 'product';
     $item->rcm_active = $this->_premoderation ? 0 : 1;
     //$item->rcm_parent_id = 0;
     $item->rcm_parent_id = strip_tags(stripslashes($this->request('parent_id')));
     if ($this->getCurrentUser() and $this->getCurrentUser()->u_id) {
         $item->rcm_nickname = $this->getCurrentUser()->u_login;
         $item->rcm_user_id = $this->getCurrentUser()->u_id;
     } else {
         // @TODO: What really should we do if user is anonymous?
         $item->rcm_nickname = strip_tags(stripslashes($this->request('nickname')));
         $item->rcm_user_id = 0;
     }
     $item->rcm_item_id = (int) $this->request('p');
     $item->rcm_text = strip_tags(stripslashes($this->request('txt')));
     $table = new model_core_table('comments', 'coreresource');
     $table->insertItem($item);
     $item->rcm_id = $table->inserted_id();
     $parentComm = $table->getItem($item->rcm_parent_id);
     $modelUser = rad_instances::get('model_core_users');
     if ($parentComm->rcm_user_id != 0) {
         $userCommParent = $modelUser->getItem($parentComm->rcm_user_id);
         if (filter_var($userCommParent->u_email, FILTER_VALIDATE_EMAIL)) {
             //$link_to_comment = $this->makeURL('alias=product&products_action=i&i='.$item->rcm_id);
             $link_to_comment = $this->makeURL('alias=product&p=' . $item->rcm_item_id);
             $this->_sendMail($userCommParent->u_email, $item->rcm_text, $parentComm->rcm_text, $link_to_comment);
         }
     }
     //$this->_sendMail($parent->rcm_user_id);
 }
Example #10
0
 function __construct()
 {
     if ($this->getParamsObject()) {
         $params = $this->getParamsObject();
         $this->setVar('params', $params);
     }
     $this->setVar('hash', $this->hash());
     if ($this->request('action')) {
         $this->addBC('action', $this->request('action'));
         $this->setVar('action', $this->request('action'));
         switch ($this->request('action')) {
             case 'install':
                 break;
             case 'network':
                 break;
             case 'getjs':
                 $this->setVar('main_action', $this->request('ma'));
                 $this->setVar('current_lang', $this->getCurrentLang());
                 break;
             case 'getnodes':
                 if ($this->request('ma') == 'install') {
                     $this->getLocalNodes();
                 } elseif ($this->request('ma') == 'network') {
                     $this->getNetworkNodes();
                 } else {
                     $this->securityHoleAlert(__FILE__, __LINE__, $this->getClassName());
                 }
                 break;
             case 'getinc':
                 //GETS the include
                 $this->getIncludeInfo();
                 break;
             case 'getmod':
                 //Gets the module
                 $this->setVar('subaction', 'getmod');
                 if ((int) $this->request('i')) {
                     $table = new model_core_table('modules');
                     $this->setVar('item', $table->getItem((int) $this->request('i')));
                 } else {
                     $this->setVar('i', $this->request('i'));
                 }
                 break;
             case 'getxmlparamsstring':
                 $this->getXMLParamsString();
                 break;
             case 'getParamsSettings':
                 $this->getParamsSettings();
                 break;
             case 'savexmlparamsstring':
                 $this->saveXMLParamsString();
                 break;
             case 'getfullxmlparams':
                 $this->getFullXMLParamsString();
                 break;
             case 'savefullxmlparams':
                 $this->saveFullXMLParamsString();
                 break;
             case 'installXML':
                 $this->installXML();
                 break;
             case 'saveinclude':
                 echo $this->saveInclude();
                 break;
             case 'getfile':
                 $this->setVar('params', '');
                 $system = new stdClass();
                 $system->module = new stdClass();
                 $system->module->folder = $this->request('folder');
                 $system->module->filename = $this->request('fn');
                 $this->setVar('system', $system);
                 $names = new stdClass();
                 $names->url = 'http://';
                 $this->setVar('names', $names);
                 break;
             case 'validateXML':
                 $this->validateXML();
                 break;
             case 'deleteComponent':
                 $this->deleteComponent();
                 break;
             default:
                 $this->securityHoleAlert(__FILE__, __LINE__, $this->getClassName());
                 break;
         }
     }
 }
Example #11
0
 protected function activateUser()
 {
     $c = urldecode($this->request('c'));
     $this->setVar('onlymessage', true);
     if ($c) {
         $this->setVar('action', 'c');
         $model = rad_instances::get('model_core_users');
         $model->setState('code', $c);
         $user = $model->getItem();
         if (isset($user->u_id) and $user->u_id) {
             if ($user->u_email_confirmed) {
                 $table = new model_core_table('subscribers_activationurl', 'coremail');
                 $table->setState('sac_url', $c);
                 $activation = $table->getItem();
                 if ($activation) {
                     if ($model->emailExists($activation->email, $user->u_id)) {
                         $this->setVar('message', $this->lang('mail_alreadyregistred.registration.text', null, true));
                     } else {
                         $user->u_email = $activation->email;
                         $model->updateItem($user);
                         rad_session::updateUserData($user->u_id);
                         rad_instances::get('model_coremail_subscribes')->confirm($c);
                         $this->setVar('message', $this->lang('subscribers.mailactivated.text', null, true));
                     }
                 } else {
                     $this->setVar('message', $this->lang($this->config('registration.code_not_found')));
                 }
             } elseif (!($error = $this->beforeActivateUser($user))) {
                 $user->u_email_confirmed = 1;
                 $model->updateItem($user);
                 rad_instances::get('model_coremail_subscribes')->confirm($c);
                 /* make referals component */
                 if ($this->config('referals.on') and class_exists('struct_coresession_referals_users')) {
                     $this->setReferral($user);
                 }
                 $this->setVar('message', $this->lang($this->config('registration.mailactivated_text')));
                 //send message to user
                 $this->_sendMail($user, 'register_ok');
                 $this->_sendMail($user, 'send_admin');
             } else {
                 $this->setVar('message', is_array($error) ? implode('<br />', $error) : $error);
             }
         } else {
             //code not found
             $this->setVar('message', $this->lang($this->config('registration.code_not_found')));
         }
     } else {
         $this->securityHoleAlert(__FILE__, __LINE__, $this->getClassName());
     }
 }
Example #12
0
 /**
  * Changes the position of the answer
  * @return JS
  */
 function moveAnswer()
 {
     if ($this->request('hash') == $this->hash()) {
         $item_id = (int) $this->request('id');
         if ($item_id) {
             $table = new model_core_table('votes_questions', 'coreothers');
             $item = $table->getItem($item_id);
             $item->vtq_position = (int) $this->request('v');
             if ($item->vtq_position and $item_id) {
                 $table->updateItem($item);
                 echo 'RADVotesQuestions.message("' . addslashes($this->lang('updatedrows.system.message ')) . ': 1");';
                 echo 'RADVotesQuestions.refresh();';
             }
         } else {
             $this->securityHoleAlert(__FILE__, __LINE__, $this->getClassName());
         }
     } else {
         $this->securityHoleAlert(__FILE__, __LINE__, $this->getClassName());
     }
 }
Example #13
0
 /**
  * Copy components from theme
  */
 private function copyComponentsFromTheme()
 {
     $theme = trim($this->request('theme'));
     $alias_id = (int) $this->request('alias_id');
     $from = trim($this->request('from'));
     if ($alias_id && $theme != $from && (!$from || is_dir(THEMESPATH . $from)) && (!$theme || is_dir(THEMESPATH . $theme))) {
         $model = rad_instances::get('model_core_aliases');
         if (strlen($from)) {
             $model->setState('theme', $from);
         }
         $item = $model->getItem($alias_id);
         $struct = new struct_core_includes_in_aliases();
         if ($theme) {
             $table = new model_core_table('themes');
             $table->setState('where', 'theme_aliasid=' . $alias_id . ' and theme_folder="' . $theme . '"');
             $themes_obj = $table->getItem();
             $struct->theme_id = $themes_obj->theme_id;
         }
         $struct->alias_id = $alias_id;
         if (!empty($item->includes)) {
             $this->deleteComponentsFromTheme($alias_id, $theme);
             $ret = true;
             foreach ($item->includes as $include) {
                 /** @var struct_core_include $include */
                 $struct->include_id = $include->inc_id;
                 $struct->controller = $include->controller;
                 $struct->order_sort = $include->order_sort;
                 $struct->position_id = $include->rp_id;
                 $struct->params_hash = $include->params_hash;
                 $model = rad_instances::get('model_core_includes');
                 if (!$model->insertItem($struct)) {
                     $ret = false;
                     break;
                 }
             }
             $this->clearAliasCache(rad_instances::get('model_core_aliases')->getItem($struct->alias_id));
             if (!$ret) {
                 echo "ERROR!!!! '.__LINE__.' Problem in DB";
             }
         } else {
             echo $this->lang('nocomponentstocopy.aliases.error');
         }
     } else {
         $this->securityHoleAlert(__FILE__, __LINE__, $this->getClassName());
     }
 }