/**
 * Mantis 1.2 only !!
 * remove existing entries from mantis menu
 *
 * @param string $name 'CodevTT'
 */
function removeCustomMenuItem($name)
{
    // get current mantis custom menu entries
    $query = "SELECT value FROM `mantis_config_table` WHERE config_id = 'main_menu_custom_options'";
    $result = execQuery($query);
    $serialized = 0 != mysql_num_rows($result) ? mysql_result($result, 0) : NULL;
    // add entry
    if (!is_null($serialized) && "" != $serialized) {
        $menuItems = unserialize($serialized);
        foreach ($menuItems as $key => $item) {
            if (in_array($name, $item)) {
                echo "remove key={$key}<br>";
                unset($menuItems[$key]);
            }
        }
        $newSerialized = serialize($menuItems);
        // update mantis menu
        if (NULL != $serialized) {
            $query = "UPDATE `mantis_config_table` SET value = '{$newSerialized}' " . "WHERE config_id = 'main_menu_custom_options'";
        } else {
            $query = "INSERT INTO `mantis_config_table` (`config_id`, `value`, `type`, `access_reqd`) " . "VALUES ('main_menu_custom_options', '{$newSerialized}', '3', '90');";
        }
        $result = execQuery($query);
    } else {
        // echo "no custom menu entries found<br>";
    }
}
 function onAction()
 {
     global $application;
     $emails_keys = modApiFunc('Request', 'getValueByKey', 'emails');
     $emails_topics = modApiFunc('Request', 'getValueByKey', 'topic');
     $customer_id = modApiFunc('Request', 'getValueByKey', 'customer_id');
     if (!is_array($emails_topics)) {
         $emails_topics = array();
     }
     foreach (array_keys($emails_keys) as $email) {
         $topics = @$emails_topics[$email];
         if (!is_array($topics)) {
             $topics = array();
         }
         modApiFunc('Subscriptions', 'changeSubscriptions', $email, $topics);
         $params = array('customer_id' => $customer_id, 'email' => $email);
         execQuery('SUBSCR_LINK_SUBSCRIPTION_TO_CUSTOMER', $params);
     }
     $messages['MESSAGES'][] = getMsg('SYS', 'SUBSCRIPTIONS_UPDATED');
     modApiFunc('Session', 'set', 'AplicationSettingsMessages', $messages);
     $request = new Request();
     $request->setView(CURRENT_REQUEST_URL);
     $request->setKey('page_view', modApiFunc('Request', 'getValueByKey', 'page_view'));
     $request->setKey('customer_id', $customer_id);
     $application->redirect($request);
 }
function validaDados()
{
    global $erro;
    global $acao;
    global $sistema;
    global $diretorioarquivos;
    global $urlarquivos;
    if (empty($sistema)) {
        $erro = "SISTEMA não informado.";
        return false;
    } else {
        if (empty($diretorioarquivos)) {
            $erro = "Diretorio de Arquivos não informado.";
            return false;
        } else {
            if (empty($urlarquivos)) {
                $erro = "URL dos Arquivos não informado.";
                return false;
            }
        }
    }
    //verifica se ja existe registro cadastrado com a informaçao passada ---
    if ($acao == "Incluir") {
        $sql = "select * from sis_param where sistema = '{$sistema}'";
        if (mysql_num_rows(execQuery($sql)) > 0) {
            $erro = "Nome do Sistema já existe no cadastro.";
            return false;
        }
    }
    //-----------------------------------------------------------------------
    return true;
}
 /**
  * Returns order_id, order_date, list<price_total, currency_code, currency_type> for each order
  */
 function __fetch_base_orders_info($order_ids)
 {
     global $application;
     if (empty($order_ids)) {
         return array();
     } else {
         $res = execQuery('SELECT_BASE_ORDERS_INFO', array("order_ids" => $order_ids));
         $orders = array();
         foreach ($res as $row) {
             if (!isset($orders[$row['order_id']])) {
                 $orders[$row['order_id']] = array("order_id" => $row['order_id'], "order_date" => $row['order_date'], "payment_status_id" => $row['payment_status_id'], "person_id" => $row['person_id'], "status_id" => $row['status_id'], "price_total" => array());
             }
             $orders[$row['order_id']]["price_total"][$row['currency_code']] = array("order_total" => $row['order_total'], "order_tax_total" => $row['order_tax_total'], "currency_code" => $row['currency_code'], "currency_type" => $row['currency_type']);
         }
         //convert currency data to checkout format
         foreach ($orders as $order_id => $info) {
             $info =& $orders[$order_id];
             $order_currencies = array();
             foreach ($info['price_total'] as $price_info) {
                 $order_currencies[] = array('currency_type' => $price_info['currency_type'], 'currency_code' => $price_info['currency_code']);
             }
             $info['order_currencies_list'] = modApiFunc("Checkout", "getOrderCurrencyList", $order_id, $order_currencies);
             unset($info);
         }
         return $orders;
     }
 }
Example #5
0
function findListBoard($parentId)
{
    $strQuery = "select * from bbs_board where parentId={$parentId}";
    $result = array();
    $result = execQuery($strQuery);
    return $result;
}
Example #6
0
/**
 * This function must check the user session to be sure that he/she is
 * authorized to upload and access files in the File Browser.
 *
 * @return boolean
 */
function CheckAuthentication()
{

    //
    // Validate the user's existing session and most privileged role.
    //
    // Sessions are stored in the database. Lookup a sesion via the cookie
    // _lis_site_session. If it's valid, extract the ckfinder_role value
    // and validate it.
    //

    $cookie = $_COOKIE['_lis_site_session'];
    $value = explode('--', $cookie);
    $value = $value[0];

    $conn = dbConnect();
    $query = mysql_real_escape_string($value);
    $session = execQuery("SELECT * FROM sessions WHERE session_id = '$query'", "dbResultToArray");

    $session_data = explode("\n", $session[0]['data']);

    $valid_roles = array("superuser", "admin");

    foreach ($session_data as $s) {
        $role = preg_replace('/[^a-z]/', '', base64_decode($s));
        for ($i = 0; $i < count($valid_roles); $i++) {
            if (strstr($role, $valid_roles[$i])) {
                return true;
            }
        }
    }

	return false;
}
 function onAction()
 {
     global $application;
     $request = $application->getInstance('Request');
     $SessionPost = array();
     /*
     if(modApiFunc('Session', 'is_Set', 'SessionPost'))
     {
         _fatal(array( "CODE" => "CORE_050"), __CLASS__, __FUNCTION__);
     }
     */
     $SessionPost = $_POST;
     $nErrors = 0;
     $key = $request->getValueByKey('action_key');
     // @ check key
     $topics = $request->getValueByKey('topics');
     $selected_topics = explode(',', $topics);
     if (!is_array($selected_topics) || empty($selected_topics)) {
         // @ INTERNAL
         $SessionPost['ViewState']['ErrorsArray'][] = 'INTERNAL';
         $nErrors++;
     }
     modApiFunc('Subscriptions', 'copyTempEmails', $key);
     modApiFunc('Subscriptions', 'linkTempEmails', $key);
     modApiFunc('Subscriptions', 'subscribeTempEmails', $key, $selected_topics);
     modApiFunc('Subscriptions', 'cleanTempEmails', $key);
     execQuery('SUBSCR_LINK_CUSTOMER_EMAILS', null);
     execQuery('SUBSCR_LINK_ORDERS_EMAILS', null);
     modApiFunc('Session', 'set', 'SessionPost', $SessionPost);
     $request = new Request();
     $request->setView('Subscriptions_Manage');
     //        $request->setKey('stage', 'finish');
     $application->redirect($request);
 }
Example #8
0
 public static function order($name, $email = '', $phone = '', $address = '', $comment = '', $adminNotifyTplID = 'admin_purchase_notify', $customerNotifyTplID = 'user_purchase_notify')
 {
     global $db;
     $user = \cf\User::getLoggedIn();
     $productList = '';
     $products = \cf\api\cart\getList();
     if (!array_key_exists('contents', $products) || !count($products['contents'])) {
         return false;
     }
     $tpl = new MailTemplate('order');
     execQuery("\n\t\t\tINSERT INTO cf_orders (created,customer_name, customer_email, customer_phone, customer_address, customer_comments, comments)\n\t\t\tVALUES(NOW(),:name, :email, :phone, :address, :comments, :contents)", array('name' => $name, 'email' => $email, 'phone' => $phone, 'address' => $address, 'comments' => $comment, 'contents' => $tpl->parseBody(array('cart' => $products))));
     $orderId = $db->lastInsertId();
     $msgParams = array('name' => $name, 'email' => $email, 'phone' => $phone, 'address' => $address, 'comment' => $comment, 'order' => $orderId, 'total' => $products['total'], 'products' => $products['contents']);
     \cf\api\cart\clear();
     $mail = new \PHPMailer();
     $mail->CharSet = 'UTF-8';
     if ($adminNotifyTplID) {
         $tpl = new MailTemplate($adminNotifyTplID);
         $mail->Subject = $tpl->parseSubject($msgParams);
         $mail->MsgHTML($tpl->parseBody($msgParams));
         foreach ($tpl->recipients() as $address) {
             $mail->addAddress($address);
         }
         $mail->Send();
     }
     $mail->clearAddresses();
     if ($customerNotifyTplID && $email) {
         $tpl = new MailTemplate($customerNotifyTplID);
         $mail->Subject = $tpl->parseSubject($msgParams);
         $mail->MsgHTML($tpl->parseBody($msgParams));
         $mail->addAddress($email);
         $mail->Send();
     }
     return $orderId;
 }
function validaDados()
{
    global $erro;
    global $acao;
    global $nome;
    global $descricao;
    global $idgrupo;
    global $ativo;
    if (empty($nome)) {
        $erro = "Nome não informado.";
        return false;
    } else {
        if (empty($descricao)) {
            $erro = "Descrição não informada.";
            return false;
        }
    }
    //verifica se ja existe registro cadastrado com a informaçao passada ---
    if ($acao == "Incluir") {
        $sql = "select * from sis_grupo where nome = '{$nome}'";
    } else {
        $sql = "select * from sis_grupo where nome = '{$nome}' and idgrupo <> {$idgrupo}";
    }
    if (mysql_num_rows(execQuery($sql)) > 0) {
        $erro = "Nome do perfil já existe no cadastro.";
        return false;
    }
    //-----------------------------------------------------------------------
    return true;
}
 function onAction()
 {
     global $application;
     $this->topics = modApiFunc('Request', 'getValueByKey', 'topic');
     if (empty($this->topics)) {
         $this->topics = array();
     }
     $SessionPost = array();
     $this->email = trim(modApiFunc('Request', 'getValueByKey', 'email'));
     if (modApiFunc('Users', 'isValidEmail', $this->email)) {
         if (modApiFunc('Subscriptions', 'canClientUnsubscribe')) {
             $ViewState = $this->changeSubscriptions();
         } else {
             $ViewState = $this->addSubscriptions();
         }
         $SessionPost['ViewState'] = $ViewState;
         if ($this->signed_in) {
             $params = array('account' => $this->account, 'email' => $this->email);
             execQuery('SUBSCR_LINK_SUBSCRIPTION_TO_CUSTOMER', $params);
         } else {
             modApiFunc('Subscriptions', 'setCustomerSubscribedEmail', $this->email);
         }
     } else {
         $SessionPost['ViewState']['ErrorsArray'][] = getMsg('SUBSCR', 'ERROR_SUBSCR_INVALID_EMAIL');
     }
     modApiFunc('Session', 'set', 'SessionPost', $SessionPost);
     $r = new Request();
     $r->setView(CURRENT_REQUEST_URL);
     $r->setAnchor('subscribe_box');
     $application->redirect($r);
 }
Example #11
0
/**
 * Add a new entry in MantisBT menu (main_menu_custom_options)
 *
 * ex: addCustomMenuItem('CodevTT', '../codev/index.php')
 *
 * @param string $name
 * @param string $url
 * @return string
 */
function addCustomMenuItem($name, $url)
{
    $pos = '10';
    // invariant
    // get current mantis custom menu entries
    $query = "SELECT value FROM `mantis_config_table` WHERE config_id = 'main_menu_custom_options'";
    $result = execQuery($query);
    $serialized = 0 != mysql_num_rows($result) ? mysql_result($result, 0) : NULL;
    // add entry
    if (NULL != $serialized && "" != $serialized) {
        $menuItems = unserialize($serialized);
    } else {
        $menuItems = array();
    }
    $menuItems[] = array($name, $pos, $url);
    $newSerialized = serialize($menuItems);
    // update mantis menu
    if (NULL != $serialized) {
        $query = "UPDATE `mantis_config_table` SET value = '{$newSerialized}' " . "WHERE config_id = 'main_menu_custom_options'";
    } else {
        $query = "INSERT INTO `mantis_config_table` (`config_id`, `value`, `type`, `access_reqd`) " . "VALUES ('main_menu_custom_options', '{$newSerialized}', '3', '90');";
    }
    $result = execQuery($query);
    return $newSerialized;
}
 function markRecordAsDeleted($order_id, $order_deleted)
 {
     if ($this->isStatisticsEnable() == false) {
         return;
     }
     $params = array('order_id' => $order_id, 'order_deleted' => $order_deleted);
     execQuery('UPDATE_ORDERS_STAT_RECORD', $params);
 }
 function outputCZLayoutHTTPSSettings()
 {
     global $application;
     //1.                 Layout-   CZ    FS.
     //2.                    Layout-   CZ        .
     //3.        2                                  1,
     //                     .
     //4.               2.                          .
     $layouts_from_fs = LayoutConfigurationManager::static_get_cz_layouts_list();
     $layouts_from_bd = modApiFunc("Configuration", "getLayoutSettings");
     foreach ($layouts_from_fs as $fname => $info) {
         if (!array_key_exists($fname, $layouts_from_bd)) {
             execQuery('INSERT_LAYOUT_HTTPS_SETTINGS', array('layout_full_file_name' => $fname));
         }
     }
     $layouts_from_bd = modApiFunc("Configuration", "getLayoutSettings");
     if (sizeof($layouts_from_bd) > 0) {
         $CZHTTPSLayouts = "";
         foreach ($layouts_from_bd as $fname => $info) {
             $config = LayoutConfigurationManager::static_parse_layout_config_file($fname);
             if (!empty($config)) {
                 $this->_Template_Contents['CZHTTPSLayoutId'] = $info['id'];
                 //CZHTTPSLayouts
                 //CZHTTPSLayoutSections
                 $map = modApiFunc("Configuration", "getLayoutSettingNameByCZLayoutSectionNameMap");
                 $CZHTTPSLayoutSections = "";
                 $checked_sections = array();
                 foreach ($info as $key => $value) {
                     if (in_array($key, $map)) {
                         //
                         $this->_Template_Contents['_hinttext'] = gethinttext('HTTPS_FIELD_' . $key);
                         $this->_Template_Contents['CZHTTPSSectionName'] = getMsg('CFG', 'HTTPS_KEY_NAME_' . $key);
                         $this->_Template_Contents['CZHTTPSSectionKey'] = $key;
                         $this->_Template_Contents['CZHTTPSSectionValue'] = $value == DB_TRUE ? " CHECKED " : "";
                         if ($value == DB_TRUE) {
                             $checked_sections[] = $key;
                         }
                         $application->registerAttributes($this->_Template_Contents);
                         $CZHTTPSLayoutSections .= modApiFunc('TmplFiller', 'fill', "configuration/cz_https/", "section.tpl.html", array());
                     }
                 }
                 $this->_Template_Contents['CZHTTPSLayoutFileName'] = $fname;
                 $this->_Template_Contents['CZHTTPSLayoutURL'] = $config['SITE_URL'];
                 $this->_Template_Contents['CZHTTPSLayoutId'] = $info['id'];
                 $this->_Template_Contents['CZHTTPSLayoutSections'] = $CZHTTPSLayoutSections;
                 $this->_Template_Contents['CZHTTPSLayoutCheckedSections'] = implode('|', $checked_sections);
                 $application->registerAttributes($this->_Template_Contents);
                 $CZHTTPSLayouts .= modApiFunc('TmplFiller', 'fill', "configuration/cz_https/", "item.tpl.html", array());
             }
         }
         $this->_Template_Contents['CZHTTPSLayouts'] = $CZHTTPSLayouts;
         $application->registerAttributes($this->_Template_Contents);
         return modApiFunc('TmplFiller', 'fill', "configuration/cz_https/", "container.tpl.html", array());
     } else {
         //              : layout                    .
         return modApiFunc('TmplFiller', 'fill', "configuration/cz_https/", "container-empty.tpl.html", array());
     }
 }
Example #14
0
function findUserById($id)
{
    $strQuery = "select * from bbs_user where uId = {$id}";
    $rs = execQuery($strQuery);
    if (count($rs) > 0) {
        return $rs[0];
    }
    return $rs;
}
 function onAction()
 {
     global $application;
     $request = $application->getInstance('Request');
     $gc_code = $request->getValueByKey('gc_code');
     execQuery('DELETE_GC_BY_CODE', array("gc_code" => $gc_code));
     $request = new Request();
     $request->setView(CURRENT_REQUEST_URL);
     $application->redirect($request);
 }
Example #16
0
function findListReply($page, $topicId)
{
    $pageSize = $GLOBALS["cfg"]["server"]["page_size"];
    if ($page >= 1) {
        $page--;
    }
    $page *= $pageSize;
    $strQuery = "select * from bbs_reply r,bbs_user u where r.uId=u.uId and r.topicId={$topicId} order by publishTime desc limit {$page} , {$pageSize}";
    $rs = execQuery($strQuery);
    return $rs;
}
Example #17
0
function findListTopic($page, $boardId)
{
    $pageSize = $GLOBALS["cfg"]["server"]["page_size"];
    if ($page >= 1) {
        //分页处理
        $page--;
    }
    $page *= $pageSize;
    //分页查询
    $strQuery = "select * from bbs_topic t,bbs_user u where t.uId=u.uId and boardId={$boardId} order by publishTime desc limit {$page} ,{$pageSize}";
    $rs = execQuery($strQuery);
    return $rs;
}
 function addRecord($qty = 1)
 {
     if ($this->isStatisticsEnable() == false) {
         return;
     }
     $params = array('datetime' => date('Y-m-d H:00:00', $this->getTimestamp()), 'carts_created_qty' => $qty);
     $record = execQuery('SELECT_CARTS_STAT_RECORD_BY_PK', $params);
     if (!empty($record) and isset($record[0])) {
         $record = $record[0];
         $params['carts_created_qty'] += $record['carts_created_qty'];
     }
     execQuery('REPLACE_CARTS_STAT_RECORD', $params);
 }
Example #19
0
function fillPropertyLocations()
{
    $sql = "SELECT property_id, city, state, zip, street_number, street, county FROM property_listings WHERE IFNULL(lat, 0)=0 OR IFNULL(lon, 0)=0 LIMIT 30";
    $result = execQuery($sql);
    while ($row = mysql_fetch_assoc($result)) {
        $address = $row['street_number'] . ' ' . $row['street'] . ',' . $row['city'] . ',' . $row['state'] . ' ' . $row['zip'];
        $json = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($address) . '&sensor=false');
        $info = json_decode($json, true);
        $info = $info['results'][0]['geometry']['location'];
        if ($info) {
            execQuery("UPDATE property_listings SET lat='{$info['lat']}', lon='{$info['lng']}' WHERE property_id='{$row['property_id']}'");
        }
    }
}
 function FreeShippingRulesList()
 {
     global $application;
     $this->MessageResources =& $application->getInstance('MessageResources', "shipping-cost-calculator-messages", "AdminZone");
     $this->mTmplFiller =& $application->getInstance('TmplFiller');
     $this->rulesList = execQuery('SELECT_SCC_FS_RULES', array());
     if (modApiFunc("Session", "is_Set", "SessionPost")) {
         $this->copyFormData();
         modApiFunc('Session', 'un_Set', 'SessionPost');
     } else {
         $this->initFormData();
     }
     loadCoreFile('html_form.php');
 }
function execQueryPag($consulta)
{
    global $total;
    global $limit;
    $consulta = strtolower($consulta);
    /*$pos = strpos($consulta, "from") - 1;
    		$sql = "select count(*) as total ".substr($consulta,$pos,strlen($consulta));
    	
    		$resultado = execQuery($sql);
    		$row = mysql_fetch_assoc($resultado);
    		$total = $row["total"];*/
    $rs = execQuery($consulta);
    $total = mysql_num_rows($rs);
    return execQuery($consulta . $limit);
}
 function fetchSubscribedTopics()
 {
     $this->subscribed_topics = array();
     if (!empty($this->emails)) {
         $params = array('emails' => $this->emails, 'signed_in' => $this->signed_in);
         $res = execQuery('SUBSCR_GET_SUBSCRIBED_TOPICS_IDS', $params);
         foreach ($res as $r) {
             $this->subscribed_topics[$r['email']][$r['topic_id']] = $r['topic_id'];
         }
     }
     if (isset($this->email)) {
         $this->subscribed = @$this->subscribed_topics[$this->email];
         if (!isset($this->subscribed)) {
             $this->subscribed = array();
         }
     }
 }
function validaDados()
{
    global $erro;
    global $acao;
    global $nome;
    global $idtiposolicitacao_seguinte;
    global $idtiposolicitacao;
    global $instancia;
    if (empty($nome)) {
        $erro = "Nome não informado.";
        return false;
    } else {
        if (empty($instancia)) {
            $erro = "Instância não informada.";
            return false;
        }
    }
    //verifica se ja existe registro cadastrado com a informaçao passada ---
    if ($acao == "Incluir") {
        $sql = "select * from lda_tiposolicitacao where nome = '{$nome}'";
    } else {
        $sql = "select * from lda_tiposolicitacao where nome = '{$nome}' and idtiposolicitacao <> {$idtiposolicitacao}";
    }
    if (mysql_num_rows(execQuery($sql)) > 0) {
        $erro = "Nome do tipo de instancia já existe no cadastro.";
        return false;
    }
    //-----------------------------------------------------------------------
    //verifica se ja existe registro cadastrado como inicial
    if ($instancia == "I") {
        if ($acao == "Incluir") {
            $sql = "select * from lda_tiposolicitacao where instancia = 'I'";
        } else {
            $sql = "select * from lda_tiposolicitacao where instancia = 'I' and idtiposolicitacao <> {$idtiposolicitacao}";
        }
        if (mysql_num_rows(execQuery($sql)) > 0) {
            $erro = "Só pode existir uma instância cadastrada como inicial.";
            return false;
        }
    }
    //-----------------------------------------------------------------------
    return true;
}
Example #24
0
 public static function order($name, $email = '', $phone = '', $address = '', $comment = '', $notifyGroup = 'admin', $notifyCustomer = true)
 {
     global $db;
     $user = \cf\User::getLoggedIn();
     $productList = '';
     $products = \cf\api\cart\getList();
     if (count($products) < 2) {
         return false;
     }
     for ($i = 1; $i < count($products); ++$i) {
         $productList .= "{$products[$i]['id']} {$products[$i]['name']} [{$products[$i]['price']}] - {$products[$i]['amount']} <br>";
     }
     $productList .= "<br><strong>Итого</strong>: {$products[0]['total_price']}";
     execQuery("\n\t\t\tINSERT INTO cf_orders (created,customer_name, customer_email, customer_phone, customer_address, customer_comments, comments)\n\t\t\tVALUES(NOW(),:name, :email, :phone, :address, :comments, :products)", array('name' => $name, 'email' => $email, 'phone' => $phone, 'address' => $address, 'comments' => $comment, 'products' => $productList));
     $orderId = $db->lastInsertId();
     \cf\api\cart\clear();
     $msgParams = array('name' => $name, 'email' => $email, 'phone' => $phone, 'address' => $address, 'comment' => $comment, 'order' => $orderId, 'total' => array_shift($products), 'products' => $products);
     if ($notifyGroup) {
         $emails = query2vector("SELECT email FROM cf_users INNER JOIN cf_user_roles ON cf_users.id=cf_user_roles.user_id WHERE cf_user_roles.role_id=:id", array('id' => $notifyGroup));
         if (!empty($emails)) {
             $tpl = new MailTemplate('admin_purchase_notify');
             $mail = new \PHPMailer();
             $mail->CharSet = 'UTF-8';
             $mail->Subject = $tpl->parseSubject($msgParams);
             $mail->MsgHTML($tpl->parseBody($msgParams));
             foreach ($emails as $a) {
                 $mail->AddAddress($a);
             }
             $mail->Send();
         }
     }
     if ($notifyCustomer && $email) {
         $tpl = new MailTemplate('user_purchase_notify');
         $mail = new \PHPMailer();
         $mail->CharSet = 'UTF-8';
         $mail->Subject = $tpl->parseSubject($msgParams);
         $mail->MsgHTML($tpl->parseBody($msgParams));
         $mail->AddAddress($email);
         @$mail->Send();
     }
     return $orderId;
 }
 function onAction()
 {
     global $application;
     $SessionPost = array('ViewState' => array());
     if ($this->signed_in) {
         $this->email = modApiFunc('Request', 'getValueByKey', 'email');
         $emails = modApiFunc('Subscriptions', 'getCustomerSubscriptionEmails', $this->account);
         if (in_array($this->email, $emails)) {
             execQuery('SUBSCR_LINK_SUBSCRIPTION_TO_CUSTOMER', array('email' => $this->email, 'customer_id' => 0));
             execQuery('SUBSCR_UNSUBSCRIBE_FROM_ALL', array('email' => $this->email));
             $SessionPost['ViewState']['Messages'][] = getMsg('SUBSCR', 'MSG_SUBSCR_EMAIL_REMOVED');
         }
     } else {
     }
     modApiFunc('Session', 'set', 'SessionPost', $SessionPost);
     $r = new Request();
     $r->setView(CURRENT_REQUEST_URL);
     $r->setAnchor('subscribe_box');
     $application->redirect($r);
 }
 function savePostedData($data)
 {
     if (!is_array($data)) {
         return;
     }
     foreach ($data as $k => $v) {
         $params = array();
         if (in_array(@$v['status'], array('A', 'H', 'D'))) {
             $params['status'] = $v['status'];
         }
         if (in_array(@$v['availability'], array('A', 'R', 'C'))) {
             $params['availability'] = $v['availability'];
         }
         if (isset($v['parent_id']) && ($v['parent_id'] == 0 || _ml_strpos('/' . modApiFunc('CMS', 'getPagePath', $v['parent_id']), '/' . $k . '/') === false)) {
             $params['parent_id'] = $v['parent_id'];
         }
         if (!empty($params)) {
             $params['page_id'] = $k;
             execQuery('UPDATE_CMS_PAGE_DATA', $params);
         }
     }
 }
 function outputFsRulesSmallTable()
 {
     global $application;
     $output = '';
     $rulesList = execQuery('SELECT_SCC_FS_RULES', array());
     $this->mTmplFiller =& $application->getInstance('TmplFiller');
     if (count($rulesList) < 1) {
         return '<tr><td colspan=4 style="text-align: center;padding-top: 50px;">' . getMsg('SCC', 'FS_EMPTY_LIST_MESSAGE') . '</td>';
     }
     foreach ($rulesList as $rule) {
         $cats = explode('|', $rule['cats']);
         $prods = explode('|', $rule['prods']);
         $cats_num = !(isset($cats[0]) && $cats[0] != NULL) ? '0' : count($cats);
         $prods_num = !(isset($prods[0]) && $prods[0] != NULL) ? '0' : count($prods);
         $cat_prod = $cats_num . '/' . $prods_num;
         $strict_cart_label = $rule['dirty_cart'] == 1 ? getMsg("SCC", "NO_LABEL") : getMsg("SCC", "YES_LABEL");
         $template_contents = array("RuleName" => $rule['rule_name'], "MinSubtotal" => $rule['min_subtotal'] > 0 ? modApiFunc("Localization", "format", $rule['min_subtotal'], "currency") : "-", "Cat_Prod" => $cat_prod, "DirtyCart" => $strict_cart_label);
         $this->_Template_Contents = $template_contents;
         $application->registerAttributes($this->_Template_Contents);
         $output .= $this->mTmplFiller->fill("shipping_cost_calculator/", "one_rule_smt.tpl.html", array());
     }
     return $output;
 }
function validaDados()
{
    global $erro;
    global $acao;
    global $idsecretaria;
    global $nome;
    global $sigla;
    global $telefonecontato;
    global $ativado;
    global $emailsic;
    global $siccentral;
    if (empty($nome)) {
        $erro = "Nome não informado.";
        return false;
    } elseif (empty($sigla)) {
        $erro = "Sigla não informada.";
        return false;
    }
    if (empty($ativado)) {
        $ativado = "0";
    }
    if (empty($siccentral)) {
        $siccentral = "0";
    }
    //verifica se ja existe registro cadastrado com a informaçao passada ---
    if ($acao == "Incluir") {
        $sql = "select * from sis_secretaria where sigla = '{$sigla}'";
    } else {
        $sql = "select * from sis_secretaria where sigla = '{$sigla}' and idsecretaria <> {$idsecretaria}";
    }
    if (mysql_num_rows(execQuery($sql)) > 0) {
        $erro = "Já existe SIC cadastrada com a sigla informada";
        return false;
    }
    //-----------------------------------------------------------------------
    return true;
}
?>
">
<table align="center" cellpadding="0" cellspacing="1">
	<tr>
		<td>
                        <?php 
if (!Solicitacao::existeSicCentralizador()) {
    //exibe SIC's caso não exista centralizador
    ?>
			<tr>
				<td align="left">
                                    Destino:
                                    <select name="idsecretariaselecionada" id="idsecretaria">
                                            <option value="">----</option>		
                                            <?php 
    $rsSic = execQuery("select idsecretaria, nome from sis_secretaria where ativado = 1 order by nome");
    ?>
                                            <?php 
    while ($rowSic = mysql_fetch_array($rsSic)) {
        ?>
                                                        <option value="<?php 
        echo $rowSic['idsecretaria'];
        ?>
" <?php 
        echo $rowSic['idsecretaria'] == $idsecretariaselecionada ? "selected" : "";
        ?>
><?php 
        echo $rowSic['nome'];
        ?>
</option>
                                            <?php 
 /**
  *                        ,                                    .
  *                                                                         ,
  *                 -                                     ,
  *                      checkout        .
  *
  * @param unknown_type $id
  */
 function getOrderCurrencyList($id, $db_data = NULL)
 {
     if ($db_data === NULL) {
         $result = execQuery('SELECT_ORDER_CURRENCY_LIST_BY_ORDER_ID', array('order_id' => $id));
     } else {
         $result = $db_data;
     }
     $res = array();
     foreach ($result as $info) {
         $res[$info['currency_type']] = $info;
     }
     if (!isset($res[CURRENCY_TYPE_CUSTOMER_SELECTED])) {
         $res[CURRENCY_TYPE_CUSTOMER_SELECTED] = $res[CURRENCY_TYPE_MAIN_STORE_CURRENCY];
     }
     if (!isset($res[CURRENCY_TYPE_PAYMENT_GATEWAY])) {
         $res[CURRENCY_TYPE_PAYMENT_GATEWAY] = $res[CURRENCY_TYPE_MAIN_STORE_CURRENCY];
     }
     return $res;
 }