Beispiel #1
0
 /**
  * Add html tag to the <head> section
  * @static
  * @param $module
  * @param $filename
  * @param $html
  */
 public static function addFile($module, $filename, $html, $priority = 0)
 {
     //TODO: decide what should we do if the same $module/$filename is called multiple times with different $html.
     $isMain = rad_instances::isMainTemplate();
     $_isMain = $isMain ? 0 : 1;
     //Main template files first!
     if (isset(self::$file_info[$module][$filename])) {
         self::$file_info[$module][$filename]['templates'][] = rad_instances::getCurrentTemplate();
         if ($_isMain > self::$file_info[$module][$filename]['main']) {
             return;
         }
         //NB: We don't need to update priority, since files added in the main template are always loaded
         //before files, added in other templates.
         $old = self::$file_info[$module][$filename];
         if ($old['priority'] > $priority || $old['main'] > $_isMain) {
             self::$file_info[$module][$filename]['main'] = $_isMain;
             self::$file_info[$module][$filename]['priority'] = $priority;
             unset(self::$files[$old['main']][$old['priority']][$module][$filename]);
             self::$files[$_isMain][$priority][$module][$filename] = $html;
         }
     } else {
         self::$file_info[$module][$filename] = array('templates' => array(rad_instances::getCurrentTemplate()), 'main' => $_isMain, 'priority' => $priority);
         self::$files[$_isMain][$priority][$module][$filename] = $html;
     }
 }
 function __construct()
 {
     if ($this->getParamsObject()) {
         $params = $this->getParamsObject();
         $this->_itemsPerPage = (int) $params->itemsperpage;
         $this->setVar('params', $params);
     }
     $pId = (int) $this->request('p');
     if ($pId) {
         $modelProduct = rad_instances::get('model_corecatalog_catalog');
         $product = $modelProduct->getItem($pId);
         if ($product->cat_id) {
             $modelTags = rad_instances::get('model_coreresource_tags');
             $modelTags->setState('tag_type', 'product');
             $similarProducts = $modelTags->getItemsWithSimilarTags($product, $this->_itemsPerPage);
             if (!empty($similarProducts)) {
                 $i = 0;
                 $model_images = rad_instances::get('model_core_image');
                 foreach ($similarProducts as &$product) {
                     $model_images->setState('cat_id', $product->cat_id);
                     $product->images_link = $model_images->getItems();
                 }
                 $this->setVar('recommendProducts', $similarProducts);
             }
         }
     }
 }
Beispiel #3
0
 function __construct()
 {
     if (!$this->config('referals.on')) {
         $this->redirect($this->makeUrl('alias=' . $this->config('defaultAlias')));
     }
     parent::__construct();
     $this->_cookieName = $this->config('referals.cookieName', $this->_cookieName);
     if ($this->getParamsObject()) {
         $params = $this->getParamsObject();
         $this->_cookieTime = $params->_get('cookie_time', $this->_cookieTime);
         $this->setVar('params', $params);
     }
     if ($this->cookie($this->_cookieName)) {
         //TODO обработать несуществующий куки, добавить значит по юзерайди.
         $model = rad_instances::get('model_coresession_referals');
         if ($item = $model->setState('cookie', $this->cookie($this->_cookieName))->getItem()) {
             $item->rrf_date = now();
             $item->rrf_time = now();
             setcookie($this->_cookieName, $item->rrf_cookie, time() + $this->_cookieTime, '/', $this->config('hostname'));
             $item->save();
         } else {
             if ($this->request('user_id')) {
                 if ($user = rad_instances::get('model_core_users')->getItem((int) $this->request('user_id'))) {
                     $this->_insertItem($user->u_id);
                 }
             }
         }
     } elseif ($this->request('user_id')) {
         if ($user = rad_instances::get('model_core_users')->getItem((int) $this->request('user_id'))) {
             $this->_insertItem($user->u_id);
         }
     }
     $this->redirect(SITE_URL);
 }
Beispiel #4
0
 function __construct()
 {
     if ($this->getParamsObject()) {
         $params = $this->getParamsObject();
         $this->_pid = $params->treestart;
         $this->_countitems = $params->countitems;
         $this->_get_all_recursive = (bool) $params->get_all_recursive;
         $this->_menuEffect = $params->menueffect;
         $this->setVar('params', $params);
     }
     $model = rad_instances::get('model_coremenus_tree');
     $model->setState('pid', $this->_pid);
     $model->setState('lang', $this->getCurrentLangID());
     $model->setState('active', 1);
     $model->setState('menueffect', $this->_menuEffect);
     $cat = (int) $this->request('cat');
     if ($cat) {
         $items = $model->getItems(true);
         $this->_recSetActive($items, $cat);
     } else {
         $items = $model->getItems($params->startlevels > 1 or $this->_get_all_recursive);
         for ($i = 0; $i < count($items); $i++) {
             $items[$i]->selected = false;
         }
     }
     $this->setVar('items', $items);
     $this->setVar('menueffect', $this->_menuEffect);
     $this->addBC('items', $items);
 }
Beispiel #5
0
 public function getProductsJSON()
 {
     $model = rad_instances::get('model_coremenus_tree');
     $model->setState('pid', $this->request('npid', $this->request('pid')));
     $model->setState('lang', $this->getContentLangID());
     $items = $model->getItems();
     $nodes = array();
     $search = array('"', '&');
     $replace = array('&quot;', '&amp;');
     $modelCat = rad_instances::get('model_corecatalog_catalog');
     if (count($items)) {
         foreach ($items as $id) {
             $modelCat->clearState();
             $modelCat->setState('tre_id', $id->tre_id)->setState('lang', $this->getContentLangID());
             $productsCntInTree = (int) $modelCat->getProductsListCount();
             if (!$id->tre_islast or $productsCntInTree) {
                 $nodes[] = array('property' => array('name' => str_replace($search, $replace, $id->tre_name), 'hasCheckbox' => false), 'type' => 'folder', 'data' => array('npid' => $id->tre_id));
             } elseif ($id->tre_islast and $productsCntInTree === 0) {
                 $nodes[] = array('property' => array('name' => str_replace($search, $replace, $id->tre_name), 'hasCheckbox' => false), 'type' => 'empty');
             }
         }
     }
     $modelCat->setState('tre_id', $this->request('npid', $this->request('pid')));
     $modelCat->setState('lang', $this->getContentLangID());
     $productsInTree = $modelCat->getProductsList();
     if (count($productsInTree)) {
         foreach ($productsInTree as $product) {
             $imgLink = empty($product->img_filename) ? '' : rad_gd_image::getLinkToImage('corecatalog', $product->img_filename, 'productstree');
             $nodes[] = array('property' => array('name' => str_replace($search, $replace, $product->cat_name), 'openIconUrl' => $imgLink, 'closeIconUrl' => $imgLink), 'type' => 'file', 'data' => array('product_id' => $product->cat_id));
         }
     }
     $this->header('Content-Type: application/json');
     echo json_encode($nodes);
 }
 function assignMailTemplate()
 {
     //Ассоциируем шаблон
     $model = rad_instances::get('model_coremail_mailtemplate');
     $model->setState('name', $this->config('comments.new_comment'));
     $model->setState('lang', $this->getCurrentLangID());
     $template = $model->getItem();
     $this->setVar('mailtemplate', array($this->getCurrentLangID() => $template));
     $this->setVar('langs', $this->getAllLanguages());
     $this->setVar('currlang', $this->getCurrentLangID());
 }
Beispiel #7
0
 /**
  * Gets the fields
  *
  * @param Boolean $joinMeasurement - need to join measurement table?
  * @return array of struct_corecatalog_cat_val_names
  */
 function getItems($joinMeasurement = false, $ct_showing = false, $node_id = 0, $pid_types = 0)
 {
     $fk['measurement'] = $joinMeasurement;
     $fk['ct_showing'] = $ct_showing;
     $node_id = $node_id ? $node_id : $this->getState('node_id') ? $this->getState('node_id') : $this->getState('vl_tre_id') ? $this->getState('vl_tre_id') : ($this->getState('tre_id') ? $this->getState('tre_id') : 0);
     $pid_types = $pid_types ? $pid_types : $this->getState('pid_types', 0) ? $this->getState('pid_types') : 0;
     $result = array();
     if (!$this->getState('without_parents') and $node_id > 0 and $pid_types > 0) {
         $modelTree = rad_instances::get('model_coremenus_tree');
         $currTree = $modelTree->getItem($node_id);
         $treeToRoot = $modelTree->getCategoryPath($currTree, $pid_types, 0);
         $ids = array();
         foreach ($treeToRoot as $ttr) {
             if ($ttr->tre_id == $pid_types) {
                 continue;
             } else {
                 $ids[] = (int) $ttr->tre_id;
             }
         }
         $ids[] = $node_id;
         $this->setState('vl_tre_id', $ids);
     }
     $q = $this->getListQuery($this->getStates(), $fk);
     if ($this->getState('showSQL')) {
         print_h($q->getValues());
         die($q->toString());
     }
     if ($this->getState('return.array')) {
         return $this->queryAll($q->toString(), $q->getValues());
     }
     foreach ($this->queryAll($q->toString(), $q->getValues()) as $key) {
         $result[] = new struct_corecatalog_cat_val_names($key);
         if ($joinMeasurement) {
             $result[count($result) - 1]->ms_value = new struct_corecatalog_measurement($key);
         }
     }
     //Join the rad_cat_val_values
     if ((int) $this->getState('cat_id')) {
         $values = $this->getValValues((int) $this->getState('cat_id'));
         if (count($values)) {
             foreach ($values as $id) {
                 for ($i = 0; $i < count($result); $i++) {
                     if ($result[$i]->vl_id == $id->vv_name_id) {
                         $result[$i]->vv_values[] = $id;
                     }
                 }
                 //for $i
             }
             //foreach
         }
     }
     //if cat_id
     return $result;
 }
Beispiel #8
0
 function assignMenu()
 {
     $model = rad_instances::get('model_coremenus_tree');
     $model->setState('pid', $this->_pid);
     $model->setState('active', 1);
     $model->setState('access', !empty($this->getCurrentUser()->u_access) ? $this->getCurrentUser()->u_access : 1000);
     $items = $model->getItems(true);
     $this->addBC('items', $items);
     $curr_item = $this->getActiveMenu($items);
     $this->addBC('curr_item', $curr_item);
     $this->setVar('curr_item', $curr_item);
     $this->setVar('items', $items);
 }
 function assignTagProductsList()
 {
     $model = rad_instances::get('model_corecatalog_catalog');
     $products = array();
     if ((int) $this->request('tag')) {
         $model->setState('tag_id', (int) $this->request('tag'));
         $products = $model->getProductsList();
         if (is_array($products)) {
             $this->setVar('products', $products);
         }
     } else {
         $this->securityHoleAlert(__FILE__, __LINE__, $this->getClassName());
     }
 }
Beispiel #10
0
 function __construct()
 {
     if ($this->getParamsObject()) {
         $this->setVar('params', $this->getParamsObject());
     }
     $model = rad_instances::get('model_corecatalog_currency');
     $items = $model->getItems();
     foreach ($items as $id) {
         if ($id->cur_default_site) {
             $this->setVar('currCurrency', $id);
             break;
         }
     }
     $this->setVar('items', $items);
 }
Beispiel #11
0
 /**
  * main init function
  *
  */
 function manage()
 {
     $tree = rad_instances::get('model_coremenus_tree');
     $tree->setState('tre_active', 1);
     $tree->setState('pid', $this->_pid);
     $tree->setState('order', 'tre_position');
     $tree->setState('access', $this->getCurrentUser()->u_access);
     $this->setVar('items', $tree->getItems(true));
     $this->setVar('user_params', $this->getCurrentUserParams());
     $model = new model_core_lang();
     $langs = $model->getItems();
     $this->setVar('langs', $langs);
     $model->setState('where', 'lng_active = 1');
     $this->setVar('langs_interface', array_reverse($model->getItems()));
     $this->setVar('contentLngId', $this->getContentLangID());
 }
Beispiel #12
0
 function save()
 {
     if ($this->request('hash') == $this->hash()) {
         $newParams = array();
         foreach ($this->_allowedConfigFields as $acf) {
             $getacf = $this->request(str_replace('.', '__', $acf));
             //beacuse we can't get form params with "." in name
             if ($getacf !== NULL) {
                 $newParams[$acf] = $getacf;
             }
         }
         if ($this->validateParams($newParams)) {
             $modelSettings = rad_instances::get('model_core_settings');
             $modelSettings->updateItemsByfldName($newParams);
             rad_config::setParam('lang.location_show', $newParams['lang.location_show']);
             header('Location: ' . $this->makeUrl('alias=' . SITE_ALIAS));
         }
     } else {
         $this->securityHoleAlert(__FILE__, __LINE__, $this->getClassName());
     }
 }
Beispiel #13
0
 /**
  * To init this class and select all currency rates!
  */
 public static function init()
 {
     if (!self::$_currs) {
         $_currs = rad_instances::get('model_corecatalog_currency')->getItems();
         if (count($_currs)) {
             for ($i = 0; $i < count($_currs); $i++) {
                 self::$_currs[$_currs[$i]->cur_id] = $_currs[$i];
             }
             //for i
         }
         foreach (self::$_currs as $id) {
             if (!isset($_SESSION['cur_default_site']) and $id->cur_default_site) {
                 self::$_curcours = $id;
                 break;
             } elseif (isset($_SESSION['cur_default_site']) and $_SESSION['cur_default_site'] == $id->cur_id) {
                 self::$_curcours = $id;
                 break;
             }
         }
         //foreach
     }
 }
Beispiel #14
0
 function __construct()
 {
     if ($this->getParamsObject()) {
         $params = $this->getParamsObject();
         $this->_itemsperpage = $params->_get('itemsperpage', $this->_itemsperpage);
         $this->setVar('params', $params);
         if ($params->_get('type_show', false)) {
             //last products and other onmain
             $model = rad_instances::get('model_corecatalog_catalog')->setState('active', 1)->setState('lang', $this->getCurrentLangID())->setState('join.mainimage', true)->setState('only.withimages', true)->setState('lang', $this->getCurrentLangID());
             switch ($params->_get('type_show')) {
                 case 'last':
                     $model->setState('order by', 'cat_datecreated DESC');
                     break;
                 case 'showed':
                     $model->setState('order by', 'cat_showed DESC');
                     break;
             }
             $this->setVar('items', $model->getItems($this->_itemsperpage));
         } else {
             //special offers for menu
             $model = rad_instances::get('model_corecatalog_catalog')->setState('special_offer', $params->cs_type)->setState('limit', $params->itemsperpage)->setState('where_condition', ' 1 ')->setState('lang', $this->getCurrentLangID());
             if ($params->ordering !== 0) {
                 $model->setState('order by', $params->ordering);
             }
             $items = $model->getProductsList();
             model_corecatalog_currcalc::init();
             $curCurrency = model_corecatalog_currcalc::$_curcours;
             foreach ($items as &$item) {
                 if ($item->cat_currency_id != $curCurrency->cur_id) {
                     $item->cat_cost = model_corecatalog_currcalc::calcCours($item->cat_cost, $item->cat_currency_id);
                     $item->currency_indicate = $curCurrency->cur_ind;
                 }
             }
             $this->setVar('products', $items);
         }
     }
 }
Beispiel #15
0
 function assignCurrency()
 {
     $model = rad_instances::get('model_corecatalog_currency');
     $model->setState('active', 1);
     $items = $model->getItems();
     $this->setVar('currency', $items);
 }
Beispiel #16
0
 /**
  * For showing the votes categories on the site
  */
 function assignVotesCategories()
 {
     $model = rad_instances::get('model_coremenus_tree');
     $model->setState('pid', $this->request('vcp', $this->_pid));
     $model->setState('lang', $this->getCurrentLangID());
     $items = $model->getItems();
     $this->setVar('categories', $items);
 }
 public static function setCurrentController($module)
 {
     self::$current_module = $module;
 }
Beispiel #18
0
 /**
  * ReCalc referal order sum
  * @param integer $order
  * @return boolean
  */
 function recalcOrderSum($order)
 {
     $orderPositions = array();
     rad_instances::get('model_corecatalog_order')->assignPositions($orderPositions, $order);
     $orderSum = 0;
     if (!empty($orderPositions)) {
         foreach ($orderPositions as $id) {
             $orderSum += model_corecatalog_currcalc::calcCours($id->orp_cost, $id->orp_curid) * $id->orp_count;
         }
     }
     $this->query('UPDATE ' . RAD . 'referals_orders SET rro_order_sum=:order_sum WHERE rro_order_id=:order_id', array('order_sum' => $orderSum, 'order_id' => (int) $order));
     return true;
 }
Beispiel #19
0
 function assignSuRubrics(struct_corearticles_pages $page)
 {
     $model = rad_instances::get('model_coremenus_tree');
     $currTree = $model->getItem($page->pg_tre_id);
     if (!empty($currTree->tre_id)) {
         $model->clearState();
         $model->setState('active', 1);
         $model->setState('lang', $this->getCurrentLangID());
         $model->setState('pid', $currTree->tre_pid);
         $subTrees = $model->getItems();
         $this->setVar('subTrees', $subTrees);
     }
 }
Beispiel #20
0
 /**
  * Delete brand by it ID
  * @return JavaScript for AJAX
  */
 function delBrand()
 {
     if ($this->request('hash') == $this->hash()) {
         $n_id = (int) $this->request('n_id');
         if ($n_id) {
             $item = rad_instances::get('model_corecatalog_brands')->getItem($n_id);
             $model = rad_instances::get('model_corecatalog_brands');
             $rows = $model->deleteItem(new struct_corecatalog_cat_brands(array('rcb_id' => $n_id)));
             if ($rows) {
                 echo 'RADBrand.message("' . $this->lang('deletedrows.catalog.text') . ': ' . $rows . '");';
             } else {
                 echo 'RADBrand.message("' . $this->lang('deletedrows.catalog.error') . ': ' . $rows . '");';
             }
             if ($this->_hassubcats) {
                 echo 'RADBrandTree.listBrand(RADBrandTree.getSID());';
             } else {
                 echo 'RADBrandTree.listBrand(ROOT_PID);';
             }
         } else {
             $this->securityHoleAlert(__FILE__, __LINE__, $this->getClassName());
         }
     } else {
         $this->securityHoleAlert(__FILE__, __LINE__, $this->getClassName());
     }
 }
Beispiel #21
0
 function setActive()
 {
     if ($this->request('hash') == $this->hash()) {
         $v = (int) $this->request('v');
         $item_id = (int) $this->request('c');
         if ($item_id) {
             $r = rad_instances::get('model_corearticles_pages')->setActive($item_id, $v);
             $r = ($v and $r) ? false : true;
             if ($r) {
                 echo '$("active_pages_link_' . $item_id . '_1").style.display="none";';
                 echo '$("active_pages_link_' . $item_id . '_0").style.display="";';
             } else {
                 echo '$("active_pages_link_' . $item_id . '_1").style.display="";';
                 echo '$("active_pages_link_' . $item_id . '_0").style.display="none";';
             }
         } else {
             $this->securityHoleAlert(__FILE__, __LINE__, $this->getClassName());
         }
     } else {
         $this->securityHoleAlert(__FILE__, __LINE__, $this->getClassName());
     }
 }
Beispiel #22
0
 /**
  * Makes the url from standart params
  * @param string $context
  * @param bool $url_aliases_enabled
  * @return string
  * @example makeURL('alias=index.html&page=2&itemsperpage=10&category=754')
  */
 public static function makeURL($context, $url_aliases_enabled = false)
 {
     static $alias_plugins = null;
     static $search = null;
     static $replace = null;
     if (!$alias_plugins) {
         $alias_plugins = rad_loader::getAliasInputClasses();
     }
     if (!$search) {
         $search = array('SITE_URL');
         $replace = array(SITE_URL);
         if (defined('SITE_ALIAS')) {
             $search[] = 'SITE_ALIAS';
             $replace[] = SITE_ALIAS;
         }
     }
     $c = str_replace($search, $replace, $context);
     if (is_link_external($c)) {
         return $c;
     }
     $r = strstr($c, '?');
     if ($r) {
         $c = substr($r, 1);
     }
     $r = explode('&', $c);
     $get = array();
     foreach ($r as $id) {
         $r1 = explode('=', $id);
         if (count($r1) >= 2) {
             $get[$r1[0]] = $r1[1];
         } else {
             $get[$r1[0]] = '';
         }
     }
     if (!isset($get['alias'])) {
         $get['alias'] = SITE_ALIAS;
     }
     if ($url_aliases_enabled && rad_config::getParam('cleanurl.on')) {
         if ($alias = rad_cleanurl::getAliasByParams($get)) {
             return SITE_URL . $alias;
         }
     }
     if (isset($alias_plugins[$get['alias']])) {
         $model = rad_instances::get($alias_plugins[$get['alias']]);
         $string = $model->makeurl($get);
     } else {
         if ((!count($get) or count($get) == 1 and isset($get['alias'])) and trim($get['alias']) == rad_config::getParam('defaultAlias')) {
             $string = SITE_URL;
         } else {
             if (rad_config::getParam('lang.location_show')) {
                 $string = SITE_URL . rad_lang::getCurrentLanguage() . '/' . $get['alias'] . '/';
             } else {
                 $string = SITE_URL . $get['alias'] . '/';
             }
             if (strlen($context)) {
                 foreach ($get as $prmname => $prmvalue) {
                     if ($prmname != 'alias') {
                         $string .= $prmname . '/' . $prmvalue . '/';
                     }
                 }
                 if (strpos($prmvalue, '.')) {
                     if ($string[strlen($string) - 1] == '/') {
                         $string = substr($string, 0, -1);
                     }
                 }
             }
         }
     }
     return $string;
 }
Beispiel #23
0
 /**
  * Deletes the page by it ID
  *
  * @param integer $id
  * @return integer
  */
 function deleteItemById($id)
 {
     $modelTags = rad_instances::get('model_coreresource_tags')->setState('tag_type', 'pages');
     $modelTags->deleteTagsInItem($id);
     return $this->exec('DELETE FROM ' . RAD . 'pages where pg_id=' . (int) $id);
 }
Beispiel #24
0
 function assignCurrency()
 {
     $items = rad_instances::get('model_corecatalog_currency')->getItems();
     $this->setVar('currency', $items);
     $this->setVar('currentCurrency', model_corecatalog_currcalc::getDefaultCurrencyId());
 }
Beispiel #25
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);
 }
 function showRefStatistic()
 {
     if (empty($this->getCurrentUser()->u_id) or !(int) $this->getCurrentUser()->u_id) {
         $this->redirect('alias=' . $this->config('alias.siteloginform'));
     }
     $this->setVar('ref_link', model_coresession_referals::makeUrl($this->getCurrentUser()->u_id, array('type' => model_coresession_referals::TYPE_INDEX)));
     $dateFrom = strtotime($this->request('datefrom', date('Y-m-d', strtotime('-' . $this->_refItemsPerPage . ' days'))));
     $dateTo = strtotime($this->request('dateto', date('Y-m-d')));
     $this->setVar('date_from', $dateFrom);
     $this->setVar('date_to', $dateTo);
     $model = rad_instances::get('model_coresession_referals')->setState('rrf_user_id', $this->getCurrentUser()->u_id)->setState('date.from', $dateFrom)->setState('date.to', $dateTo)->setState('group', 'rrf_date')->setState('select.subcount', true)->setState('order by', 'rrf_date DESC');
     $referals = $model->getItems();
     $this->setVar('partner_percent', $model->getParntnerPercent());
     /*Gets the statistif for orders and percents*/
     $orders = $model->getPartnerOrders();
     $referalsOrders = array();
     if ($orders) {
         foreach ($orders as &$order) {
             $referalsOrders[strtotime(date($this->config('date.format'), strtotime($order->order_dt)))]['orders'][] = $order;
         }
     }
     if ($referals) {
         foreach ($referals as &$referal) {
             $referalsOrders[strtotime($referal->rrf_date)]['referals'][] = $referal;
         }
     }
     $this->setVar('referals_orders', $referalsOrders);
     $this->setVar('referals_closed_order', $this->_refOrderStatus);
     $this->setVar('currency_precision', $this->config('currency.precision'));
     //         $this->setVar('referals', $referals);
 }
Beispiel #27
0
 function assignItem()
 {
     if ((int) $this->request('i')) {
         $table = new model_core_table('comments', 'coreresource');
         $item = rad_instances::get('model_coreresource_comments')->setState('active', 1)->setState('type', $this->request('t'))->getItem((int) $this->request('i'));
         if ($item->rcm_id) {
             $this->setVar('item', $item);
             $this->addBC('item', $item);
         } else {
             $this->redirect(SITE_URL);
         }
     } else {
         $this->redirect(SITE_URL);
     }
 }
Beispiel #28
0
 /**
  * Register new user
  * @param struct_core_users $item
  */
 public function register($item, $encode_password = true)
 {
     $item->u_active = 1;
     $item->u_subscribe_active = 1;
     $item->u_subscribe_langid = $this->getCurrentLangID();
     $clearpass = empty($item->u_pass) ? rad_session::genereCode(6) : $item->u_pass;
     $item->u_pass = $encode_password ? rad_session::encodePassword($clearpass) : $clearpass;
     $this->insertItem($item);
     $item->u_id = $this->inserted_id();
     rad_instances::get('model_coremail_subscribes')->removeExpired();
     $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();
     $item_url->save();
     rad_mailtemplate::send($item->u_email, $this->config('registration.template'), array('user' => $item, 'link' => rad_input::makeURL('alias=register&c=' . urlencode($item_url->sac_url)), 'clearpass' => $clearpass), $this->config('mail_format', 'html'));
 }
Beispiel #29
0
 /**
  * Deletes the article by it ID
  *
  * @param integer or array $id
  * @return integer
  */
 function deleteItemById($id)
 {
     if (is_array($id)) {
         return $this->exec('DELETE FROM ' . RAD . 'articles where art_id in ' . implode(',', $id));
     } else {
         $modelTags = rad_instances::get('model_coreresource_tags')->setState('tag_type', 'articles');
         $modelTags->deleteTagsInItem($id);
         return $this->exec('DELETE FROM ' . RAD . 'articles where art_id=' . (int) $id);
     }
 }
 function send()
 {
     if ($this->hash() == $this->request('hash')) {
         $req = $this->getAllRequest();
         if ($this->_verifyInputData($req)) {
             $template = $req['FCKeditorMailBody'];
             $vars = array('%%SITE_URL%%' => 'SITE_URL');
             $params = array('fromName' => $req['mailfromname'], 'fromEmail' => $req['mailfromemail'], 'Subject' => $req['mailsubject'], 'smtp' => '', 'format' => 'text/plain', 'header' => 'X-Priority: 1 (Higuest)');
             if ($req['mailformat'] === '0') {
                 $params['format'] = 'text/html';
             }
             if (isset($req['mailsmtp']) and $req['mailsmtp'] === 'on') {
                 $params['smtp'] = array('host' => $req['smtphost'], 'port' => (int) $req['smtpport'], 'user' => $req['smtpuser'], 'password' => $req['smtppass'], 'security' => '');
                 if ($req['smtpsecurity'] !== 'none') {
                     $params['smtp']['security'] = $req['smtpsecurity'];
                 }
             }
             $model = rad_instances::get('model_core_users');
             $model->setState('select', 'count(*)');
             $model->setState('u_group', array_values($req['mailgroups']));
             $model->setState('u_subscribe_active', 1);
             $model->setState('u_subscribe_langid', (int) $this->getCurrentLangID());
             $countUsers = $model->getItem(false);
             $model->unsetState('select');
             for ($cnt = 0; $cnt < $countUsers; $cnt += $this->_mailperiteration) {
                 $limit = $cnt . ',' . ($cnt + $this->_mailperiteration);
                 $usersArr = NULL;
                 $usersItems = $model->getItems($limit);
                 if (count($usersItems)) {
                     foreach ($usersItems as $user) {
                         if (empty($user->u_fio)) {
                             $usersArr[] = $user->u_email;
                         } elseif (!empty($user->u_fio) and !empty($user->u_email)) {
                             $usersArr[] = array($user->u_fio => $user->u_email);
                         } else {
                             continue;
                         }
                     }
                 }
                 if (count($usersArr)) {
                     rad_mailtemplate::sendMasTemplate($usersArr, $template, $vars, $params);
                 } else {
                     $this->setVar('message', $this->lang('emailsnotfound.mail.error'));
                 }
             }
             $this->setVar('message', '<span style="color:green">' . $this->lang('deliverycomplete.mail.text') . '</span>');
         }
         $this->assignUserGroups();
     } else {
         $this->securityHoleAlert(__FILE__, __LINE__, $this->getClassName());
     }
 }