Inheritance: implements sql, implements persistance
 public function initContent()
 {
     parent::initContent();
     $params = KwixoURLCallFrontController::ManageUrlCall();
     $payment_ok = $params['payment_status'];
     $errors = $params['errors'];
     $id_order = $params['id_order'];
     if ($id_order != false) {
         $order = new Order($id_order);
         $cart = new Cart($order->id_cart);
         $products = $cart->getProducts();
         $amount = $order->total_paid_tax_incl;
         $total_shipping = $order->total_shipping;
     } else {
         $products = false;
         $amount = false;
         $total_shipping = false;
     }
     $link = new Link();
     $this->context->smarty->assign('payment_ok', $payment_ok);
     $this->context->smarty->assign('errors', $errors);
     $this->context->smarty->assign('amount', $amount);
     $this->context->smarty->assign('total_shipping', $total_shipping);
     $this->context->smarty->assign('products', $products);
     $this->context->smarty->assign('path_order', $link->getPageLink('order', true));
     $this->context->smarty->assign('path_history', $link->getPageLink('history', true));
     $this->context->smarty->assign('path_contact', $link->getPageLink('contact', true));
     $this->setTemplate('urlcall.tpl');
 }
Example #2
0
 protected function _prepareHook($params)
 {
     $languages = Language::getLanguages(true, $this->context->shop->id);
     if (!count($languages)) {
         return false;
     }
     $link = new Link();
     if ((int) Configuration::get('PS_REWRITING_SETTINGS')) {
         $default_rewrite = array();
         if (Dispatcher::getInstance()->getController() == 'product' && ($id_product = (int) Tools::getValue('id_product'))) {
             $rewrite_infos = Product::getUrlRewriteInformations((int) $id_product);
             foreach ($rewrite_infos as $infos) {
                 $default_rewrite[$infos['id_lang']] = $link->getProductLink((int) $id_product, $infos['link_rewrite'], $infos['category_rewrite'], $infos['ean13'], (int) $infos['id_lang']);
             }
         }
         if (Dispatcher::getInstance()->getController() == 'category' && ($id_category = (int) Tools::getValue('id_category'))) {
             $rewrite_infos = Category::getUrlRewriteInformations((int) $id_category);
             foreach ($rewrite_infos as $infos) {
                 $default_rewrite[$infos['id_lang']] = $link->getCategoryLink((int) $id_category, $infos['link_rewrite'], $infos['id_lang']);
             }
         }
         if (Dispatcher::getInstance()->getController() == 'cms' && (($id_cms = (int) Tools::getValue('id_cms')) || ($id_cms_category = (int) Tools::getValue('id_cms_category')))) {
             $rewrite_infos = isset($id_cms) && !isset($id_cms_category) ? CMS::getUrlRewriteInformations($id_cms) : CMSCategory::getUrlRewriteInformations($id_cms_category);
             foreach ($rewrite_infos as $infos) {
                 $arr_link = isset($id_cms) && !isset($id_cms_category) ? $link->getCMSLink($id_cms, $infos['link_rewrite'], null, $infos['id_lang']) : $link->getCMSCategoryLink($id_cms_category, $infos['link_rewrite'], $infos['id_lang']);
                 $default_rewrite[$infos['id_lang']] = $arr_link;
             }
         }
         $this->smarty->assign('lang_rewrite_urls', $default_rewrite);
     }
     return true;
 }
Example #3
0
 function countLinks($categoryName)
 {
     App::import('Model', 'Link');
     $link = new Link();
     $settings = array('conditions' => array('LinkCategory.name' => $categoryName));
     return $link->find('count', $settings);
 }
/**
 * Liefert das Userprofil zur klein-Anzeige (neben Posts)
 * 
 * @param $id           ID des Users
 */
function getUserprofileForUserId($id)
{
    $sql = "SELECT * FROM user where id = '" . $id . "' ";
    $res = $_SESSION['config']->DBCONNECT->executeQuery($sql);
    $retRow = mysql_fetch_array($res);
    $ft = new FontType();
    $ft->setBold(true);
    $ft->setFontsize(3);
    $picLnk = new Link("includes/user/show_userprofil.php?showUserId=" . $id, getUserImageSourceByPicname($retRow['pic'], 80));
    $picLnk->setPopup(true);
    $status = new Text("<b>Status:</b> " . $retRow['Status']);
    $status->setFilter(false);
    $posts = new Text("<b>Posts:</b> " . $retRow['Posts']);
    $posts->setFilter(false);
    $tbl = new Table(array(""));
    $r1 = $tbl->createRow();
    $r1->setFonttype($ft);
    $r1->setAttribute(0, $retRow['Vorname'] . " " . $retRow['Nachname']);
    $tbl->addRow($r1);
    $r2 = $tbl->createRow();
    $r2->setAttribute(0, $picLnk);
    $tbl->addRow($r2);
    $r3 = $tbl->createRow();
    $r3->setAttribute(0, $status);
    $tbl->addRow($r3);
    $r4 = $tbl->createRow();
    $r4->setAttribute(0, $posts);
    $tbl->addRow($r4);
    return $tbl;
}
Example #5
0
 public function sendQuestion()
 {
     if (Tools::getValue('enviar_mensaje')) {
         $params = array();
         $params['nombre'] = pSQL(Tools::getValue('nombre', ''));
         $params['email'] = pSQL(Tools::getValue('email', ''));
         $params['ciudad'] = pSQL(Tools::getValue('ciudad', ''));
         $params['provincia'] = pSQL(Tools::getValue('provincia', ''));
         $params['consulta'] = pSQL(Tools::getValue('consulta', ''));
         $params['id_producto'] = (int) Tools::getValue('id_producto', 0);
         $params['date_add'] = date('Y-m-d H:i:s', strtotime('now'));
         $params['validado'] = 0;
         DB::getInstance()->insert('lgconsultas', $params);
         $id_consulta = Db::getInstance()->Insert_ID();
         if ($id_consulta) {
             $consulta = Db::getInstance()->getRow('SELECT * FROM `' . _DB_PREFIX_ . 'lgconsultas` WHERE id_consulta=' . (int) $id_consulta);
             $producto = Db::getInstance()->getValue('SELECT name FROM ' . _DB_PREFIX_ . 'product_lang WHERE id_product=' . (int) $consulta['id_producto'] . ' AND id_lang=' . (int) Configuration::get('PS_LANG_DEFAULT'));
             $enlace = new Link();
             $urlproducto = $enlace->getProductLink($consulta['id_producto']);
             $templateVars = array('id_consulta' => $id_consulta, '{consulta}' => pSQL($consulta['consulta']), '{nombre}' => pSQL($consulta['nombre']), '{email}' => pSQL($consulta['email']), '{provincia}' => pSQL($consulta['provincia']), '{ciudad}' => pSQL($consulta['ciudad']), '{producto}' => $producto, '{urlproducto}' => $urlproducto);
             if (!Mail::Send((int) Configuration::get('PS_LANG_DEFAULT'), 'consulta_enviada', $this->l('You have received a new question about a product'), $templateVars, Configuration::get('LG_CONSULTAS_EMAIL'), null, Configuration::get('LG_CONSULTAS_EMAIL'), Configuration::get('PS_SHOP_NAME'), null, null, _PS_MODULE_DIR_ . 'lgconsultas/mails/')) {
                 $out = array('status' => 'nok', 'msg' => $this->l('An error occurred while sending your question'));
             } else {
                 $out = array('status' => 'ok', 'msg' => $this->l('Your question has been sent'));
             }
         } else {
             $out = array('status' => 'nok', 'msg' => $this->l('An error occurred while trying to add your question'));
         }
         echo Tools::jsonEncode($out);
         die;
     }
 }
Example #6
0
function status_comment_submit($vars)
{
    global $db, $main_smarty;
    if (get_misc_data('status_switch') != '1') {
        return;
    }
    $comment = $vars['comment'];
    if (!$comment->id) {
        return;
    }
    $user = new User();
    $user->id = $comment->author;
    $linkres = new Link();
    $linkres->id = $comment->link;
    if ($user->read() && $linkres->read()) {
        if (!status_is_allowed($user) || !$user->extra_field['status_switch'] || !$user->extra_field['status_comment']) {
            return;
        }
        $main_smarty->config_load(status_lang_conf);
        $text = $main_smarty->get_config_vars('PLIGG_Status_Comment_Update');
        $limit = get_misc_data('status_max_chars');
        if ($limit > 0 && strlen($text) + strlen($user->username) + strlen($linkres->title) - 4 > $limit) {
            $linkres->title = substr($linkres->title, 0, max($limit + 4 - strlen($text) - strlen($user->username) - 3, 10)) . '...';
        }
        $text = sprintf($text, $user->username, '<a href="' . $linkres->get_internal_url() . '">' . $linkres->title . '</a>');
        $db->query($sql = "INSERT INTO " . table_prefix . "updates SET update_time=UNIX_TIMESTAMP(), \r\n\t\t\t\t\t\t\t    update_type='c',\r\n\t\t\t\t\t\t\t    update_user_id='{$comment->author}',\r\n\t\t\t\t\t\t\t    update_link_id='{$comment->id}',\r\n\t\t\t\t\t\t\t    update_text='{$text}'\r\n\t\t\t\t\t\t\t    ");
    }
}
Example #7
0
 /**
  * Shorten a new URL
  *
  * @return Response
  */
 public function postShorten()
 {
     // No big url
     if (!\Input::has('bigurl')) {
         return \Response::json(array('error' => array('code' => 'MISSING-PARAMETERS', 'http_code' => '400', 'message' => 'Bad Request')), 400);
     }
     $bigURL = \Input::get('bigurl');
     $user = $this->apiKey->user;
     // No user linked to API key - SHOULD NEVER HAPPEN
     if (!isset($user)) {
         return \Response::json(array('error' => array('code' => 'NOT-AUTH', 'http_code' => '403', 'message' => 'Forbidden: SHOULD NEVER HAPPEN!')), 403);
     }
     // User has gone over quota so cant shorten
     if ($user->quota_max != 0 && $user->quota_used + 1 > $user->quota_max) {
         return \Response::json(array('error' => array('code' => 'QUOTA-USED', 'http_code' => '400', 'message' => 'Bad Request')), 403);
     }
     if (filter_var($bigURL, FILTER_VALIDATE_URL) === false) {
         return \Response::json(array('error' => array('code' => 'URL-INVALID', 'http_code' => '400', 'message' => 'Bad Request')), 400);
     }
     $dbLink = \Link::where('destination', '=', $bigURL)->first();
     if (!isset($dbLink)) {
         $dbLink = new \Link();
         $dbLink->user_id = $user->id;
         $dbLink->code = $dbLink->generateCode();
         $dbLink->destination = $bigURL;
         $dbLink->clicks = "0";
         $dbLink->save();
         $user->quota_used += 1;
         $user->save();
     }
     $linkCode = $dbLink->code;
     $linkURL = \Request::root() . '/' . $linkCode;
     return \Response::json(array('ok' => array('code' => 'LINK-SHORTENED', 'http_code' => '200', 'message' => 'OK', 'data' => array('url' => $linkURL, 'url_code' => $linkCode))), 200);
 }
 public function initContent()
 {
     parent::initContent();
     $id = $_GET['id'];
     $id_lang = $this->context->language->id;
     $product = new Product((int) $id);
     $link = new Link();
     $url = $link->getProductLink($product);
     $features = Db::getInstance()->ExecuteS('
 		SELECT fl.name feature_name, fvl.value feature_value
 		FROM ' . _DB_PREFIX_ . 'feature_product fp
 		LEFT JOIN ' . _DB_PREFIX_ . 'feature_lang fl ON (fl.id_feature = fp.id_feature AND fl.id_lang=' . $id_lang . ' )
 		LEFT JOIN ' . _DB_PREFIX_ . 'feature_value_lang fvl ON (fvl.id_feature_value = fp.id_feature_value AND fvl.id_lang=' . $id_lang . ')
 		WHERE fp.id_product=' . $id);
     //	print_r($features);
     $images = Image::getImages((int) $id_lang, (int) $product->id);
     //Limitamos el numero de fotos a cuatro solamente
     while (count($images) > 3) {
         $var = array_pop($images);
     }
     $this->context->smarty->assign(array('product' => $product, 'lang' => $id_lang, 'image' => $images, 'dir' => Tools::getHttpHost(true) . __PS_BASE_URI__ . 'modules/pdfproduct', 'email' => Configuration::get('PS_SHOP_EMAIL'), 'url' => $url, 'address' => Configuration::get('ADDRESS_SHOP'), 'background' => Configuration::get('BACKGROUND')));
     $html = $this->context->smarty->fetch(_PS_MODULE_DIR_ . 'pdfproduct/views/templates/front/custom_template_content.tpl');
     $dompdf = new DOMPDF();
     $dompdf->set_option('enable_remote', TRUE);
     $dompdf->load_html($html);
     $dompdf->set_paper('a4', 'portrait');
     $dompdf->render();
     $dompdf->stream('producto');
     //$this->setTemplate('custom_template_content.tpl');
     //file_put_contents($filename, $dompdf->output());
     //$pdf = new PDF($product, 'CustomPdf', Context::getContext()->smarty);
     //$img_file = Tools::getHttpHost(true).__PS_BASE_URI__. '/modules/pdfproduct/views/images/background.jpg';
     //$pdf->pdf_renderer->Image($img_file, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0);
     //$pdf->render();
 }
    function displayEditForm()
    {
        global $wgOut, $wgRequest;
        $url = $wgRequest->getVal('_url');
        $title = $wgRequest->getVal('_title');
        $l = new Link();
        $link = $l->getLinkByPageID($wgRequest->getInt('id'));
        if (is_array($link)) {
            $url = htmlspecialchars($link['url'], ENT_QUOTES);
            $description = htmlspecialchars($link['description'], ENT_QUOTES);
        } else {
            $title = SpecialPage::getTitleFor('LinkSubmit');
            $wgOut->redirect($title->getFullURL());
        }
        $wgOut->setPageTitle(wfMsg('linkfilter-edit-title', $link['title']));
        $_SESSION['alreadysubmitted'] = false;
        $output = '<div class="lr-left">

			<div class="link-home-navigation">
				<a href="' . Link::getHomeLinkURL() . '">' . wfMsg('linkfilter-home-button') . '</a>';
        if (Link::canAdmin()) {
            $output .= ' <a href="' . Link::getLinkAdminURL() . '">' . wfMsg('linkfilter-approve-links') . '</a>';
        }
        $output .= '<div class="cleared"></div>
			</div>
			<form name="link" id="linksubmit" method="post" action="">
				<div class="link-submit-title">
					<label>' . wfMsg('linkfilter-url') . '</label>
				</div>
				<input tabindex="2" class="lr-input" type="text" name="lf_URL" id="lf_URL" value="' . $url . '"/>

				<div class="link-submit-title">
					<label>' . wfMsg('linkfilter-description') . '</label>
				</div>
				<div class="link-characters-left">' . wfMsg('linkfilter-description-max') . ' - ' . wfMsg('linkfilter-description-left', '<span id="desc-remaining">300</span>') . '</div>
				<textarea tabindex="3" class="lr-input" rows="4" name="lf_desc" id="lf_desc">' . $description . '</textarea>

				<div class="link-submit-title">
					<label>' . wfMsg('linkfilter-type') . '</label>
				</div>
				<select tabindex="4" name="lf_type" id="lf_type">
				<option value="">-</option>';
        $linkTypes = Link::getLinkTypes();
        foreach ($linkTypes as $id => $type) {
            $selected = '';
            if ($link['type'] == $id) {
                $selected = ' selected="selected"';
            }
            $output .= "<option value=\"{$id}\"{$selected}>{$type}</option>";
        }
        $output .= '</select>
				<div class="link-submit-button">
					<input tabindex="5" class="site-button" type="button" id="link-submit-button" value="' . wfMsg('linkfilter-submit-button') . '" />
				</div>
			</form>
		</div>';
        $output .= '<div class="lr-right">' . wfMsgExt('linkfilter-instructions', 'parse') . '</div>
		<div class="cleared"></div>';
        return $output;
    }
Example #10
0
function related_stories($storyid, $related_tags, $category)
{
    // this returns similar stories based on tags in common and in the same category
    global $db;
    if (!is_numeric($storyid)) {
        die;
    }
    $related_tags = "'" . preg_replace('/,\\s*/', "','", addslashes($related_tags)) . "'";
    // This gives us the proper string structure for IN SQL statement
    // Select 20 stories that share tags with the current story and order them by number of tags they share
    $sql = "SELECT tag_link_id, COUNT(tag_link_id) AS relevance\n\t\t\tFROM " . table_tags . "\n\t\t\tWHERE tag_words IN ({$related_tags}) AND tag_link_id!={$storyid}\n\t\t\tGROUP BY tag_link_id \n\t\t\tORDER BY relevance DESC \n\t\t\tLIMIT 20";
    $related_story = $db->get_results($sql);
    $related_story = object_2_array($related_story);
    $stories = array();
    foreach ($related_story as $id => $rs) {
        $rs2 = new Link();
        $rs2->id = $rs['tag_link_id'];
        if ($rs2->read() && ($rs2->status == 'new' || $rs2->status == 'published')) {
            $related_story[$id] = array_merge($related_story[$id], array('link_id' => $rs2->id, 'link_category' => $rs2->category, 'link_title' => $rs2->title, 'link_title_url' => $rs2->title_url));
            if ($rs2->title_url == "") {
                $related_story[$id]['url'] = getmyurl("story", $rs2->id);
            } else {
                $related_story[$id]['url'] = getmyurl("storyURL", $rs2->category_safe_names(), urlencode($rs2->title_url), $rs2->id);
            }
            $stories[] = $related_story[$id];
        }
    }
    return $stories;
}
Example #11
0
 /**
  * Method render
  * @access public
  * @param boolean $ajax_render [default value: false]
  * @return object generate html box with country flag
  * @since 1.0.35
  */
 public function render($ajax_render = false)
 {
     $lang_link = BASE_URL . $this->language . "/" . str_replace($this->getPage()->getBaseLanguageURL(), "", $this->getPage()->getCurrentURL());
     $lang_link_obj = new Link($lang_link, Link::TARGET_NONE, new Picture("wsp/img/lang/" . $this->language . ".png", 24, 24, 0, Picture::ALIGN_ABSMIDDLE));
     $this->object_change = false;
     return $lang_link_obj->render();
 }
Example #12
0
 public function attach(Link $link)
 {
     //I attach it first to a list in case I want to dynamically add or remove items
     //perhaps later I'll want to delete in an ACL ?
     $this->items[$link->getText()] = $link;
     $this->body->appendChild($this->items[$link->getText()]->getDOMNode());
 }
Example #13
0
 public function test_it_gets_link()
 {
     $Framework = new \Devise\Support\Framework();
     $cookie = [];
     $Link = new Link($Framework);
     $output = $Link->getLink($cookie);
     assertEquals('<a href="http://localhost?dir=asc" class="page-sort"></a> ', $output);
 }
Example #14
0
 public function testSettingRequest()
 {
     $request = $this->makeRequest();
     $request->expects($this->once())->method('getScriptName')->will($this->returnValue('/htdocs/test.php'));
     $link = new Link('test');
     $link->setRequest($request);
     $this->assertEquals('/htdocs/test.php?r=test', $link->getLink());
 }
 private function isPhpClass(Link $link)
 {
     $className = $link->getDestination();
     if (!class_exists($className, false)) {
         return false;
     }
     $classReflection = new \ReflectionClass($link->getDestination());
     return $classReflection->isInternal();
 }
Example #16
0
 public function testConstructor()
 {
     // Arrange
     $link = new Link('MarkdownWriter', 'https://github.com/pachico/markdownwriter');
     // Act
     $output = $link->toMarkDown();
     // Assert
     $this->assertSame('[MarkdownWriter](https://github.com/pachico/markdownwriter)', $output);
 }
 /**
  * Construct a new dropdown option.
  *
  * @param String $label the text of this dropdown
  * @param String $value the value of this form element
  * @param Link $readonlyLink (optional) a link to render instead of the
  *        label, in readonly mode.
  */
 public function __construct($label, $value, $readonlyLink = null)
 {
     parent::__construct("option");
     $this->set("value", $value);
     $this->setBody($label);
     if ($readonlyLink) {
         $readonlyLink->setTitle($label);
         $this->readonlyLink = $readonlyLink;
     }
 }
Example #18
0
 /**
  * Add new link to owner Comment
  *
  * @param integer file ID
  * @param integer link position ( 'teaser', 'aftermore' )
  * @param int order of the link
  */
 function add_link($file_ID, $position, $order)
 {
     $edited_Link = new Link();
     $edited_Link->set('cmt_ID', $this->Comment->ID);
     $edited_Link->set('file_ID', $file_ID);
     $edited_Link->set('position', $position);
     $edited_Link->set('order', $order);
     $edited_Link->dbinsert();
     // Update last touched date of the Item
     $this->item_update_last_touched_date();
 }
Example #19
0
 function __construct()
 {
     $rel = $this->rel = $_REQUEST['rel'];
     $this->id = $_REQUEST['id'];
     $moduleName = $this->module = $_REQUEST['rel_module'];
     global $beanList;
     require_once "data/Link.php";
     $beanName = $beanList[$moduleName];
     $link = new Link($this->rel, new $beanName(), array());
     $this->fields = $link->_get_link_table_definition($rel, 'fields');
 }
    public function calibrate()
    {
        //specific instruction for PS 1.5 and greater
        if (_PS_VERSION_ >= '1.5') {
            $link = new Link();
            //sets the redirection according to the action
            switch (Tools::getValue('action')) {
                //if checkoutScore, redirection to the admin order page
                case 'checkoutScore':
                    $this->redirect_after = $link->getAdminLink('AdminOrders') . "&id_order=" . Tools::getValue('id_order') . '&vieworder';
                    break;
                    //if sendOrder, redirection to the admin order page
                //if sendOrder, redirection to the admin order page
                case 'sendOrder':
                    $this->redirect_after = $link->getAdminLink('AdminOrders') . "&id_order=" . Tools::getValue('id_order') . '&vieworder';
                    break;
                    //if getAllWaitingScore, redirection to the admin orders list
                //if getAllWaitingScore, redirection to the admin orders list
                case 'getAllWaitingScores':
                    $this->redirect_after = $link->getAdminLink('AdminCertissim');
                    break;
                    //if getReevaluations, redirection to the admin orders list
                //if getReevaluations, redirection to the admin orders list
                case 'getReevaluations':
                    $this->redirect_after = $link->getAdminLink('AdminCertissim');
                    break;
                    //if unknown action
                //if unknown action
                default:
                    break;
            }
        }
        $this->_select .= ',
			IF(
				(SELECT cs.label FROM `' . _DB_PREFIX_ . 'certissim_order` c LEFT JOIN `' . _DB_PREFIX_ . 'certissim_state` cs ON c.id_certissim_state = cs.id_certissim_state WHERE c.id_order = a.id_order) = "scored",
				(SELECT c2.score FROM `' . _DB_PREFIX_ . 'certissim_order` c2 WHERE c2.id_order = a.id_order LIMIT 1),
				(
					IF(
						(SELECT count(c3.id_order) FROM `' . _DB_PREFIX_ . 'certissim_order` c3 WHERE c3.id_order=a.id_order) > 0,
						(SELECT cs2.label FROM `' . _DB_PREFIX_ . 'certissim_order` c3 LEFT JOIN `' . _DB_PREFIX_ . 'certissim_state` cs2 ON c3.id_certissim_state = cs2.id_certissim_state WHERE c3.id_order = a.id_order),
						("not concerned")
					)
				)
			)
			as score';
        $this->_join .= ' LEFT JOIN `' . _DB_PREFIX_ . 'certissim_order` cert ON (cert.`id_order` = a.`id_order`)';
        if (_PS_VERSION_ >= '1.5') {
            $column_description = array('title' => $this->l('Certissim Eval'), 'width' => 50, 'search' => true, 'icon' => array('0' => array('src' => "../../modules/fianetfraud/img/0.gif", 'alt' => 'Risque détecté'), '-1' => array('src' => "../../modules/fianetfraud/img/-1.gif", 'alt' => 'Pas de risque détecté'), '100' => array('src' => "../../modules/fianetfraud/img/100.gif", 'alt' => 'Certifiée sans risque'), 'error' => array('src' => "../../modules/fianetfraud/img/error.gif", 'alt' => 'Erreur'), 'sent' => array('src' => "../../modules/fianetfraud/img/sent.gif", 'alt' => 'Calcul du risque en cours'), 'ready to send' => array('src' => "../../modules/fianetfraud/img/ready-to-send.gif", 'alt' => 'En attente du paiement'), 'not concerned' => array('src' => "../../modules/fianetfraud/img/not-concerned.gif", 'alt' => 'Non concernée')));
            $this->fields_list['score'] = $column_description;
        } else {
            $column_description = array('title' => $this->l('Certissim Eval'), 'width' => 50, 'search' => true, 'icon' => array('0' => "../../modules/fianetfraud/img/0.gif", '-1' => "../../modules/fianetfraud/img/-1.gif", '100' => "../../modules/fianetfraud/img/100.gif", 'error' => "../../modules/fianetfraud/img/error.gif", 'sent' => "../../modules/fianetfraud/img/sent.gif", 'ready to send' => "../../modules/fianetfraud/img/ready-to-send.gif", 'default' => "../../modules/fianetfraud/img/not-concerned.gif"));
            $this->fieldsDisplay['score'] = $column_description;
        }
    }
Example #21
0
 public function displayViewLink($token = null, $id, $name = null)
 {
     $link = new Link();
     if (!array_key_exists('View', self::$cache_lang)) {
         self::$cache_lang['View'] = $this->l('View', 'Helper');
     }
     if (Module::isInstalled('agilenewsletters') and in_array($this->context->controller->table, array('agile_mail_history'))) {
         return '<a href="' . $link->getModuleLink('agilenewsletters', 'newsletterdetail', array('nid' => $id), true) . '" target="_new"><img src="../img/admin/details.gif" alt="' . self::$cache_lang['View'] . '" title="' . self::$cache_lang['View'] . '" /></a>';
     }
     return parent::displayViewLink($token, $id);
 }
 private function formatApiClass(Link $link)
 {
     $linkToClass = $this->getLinkToApiClass($link->getDestination());
     if (empty($linkToClass)) {
         return;
     }
     $description = $link->getDescription();
     $parts = explode("\\", $description);
     $description = end($parts);
     $link = sprintf('[%s](%s)', $description, $linkToClass);
     return $link;
 }
Example #23
0
 public function run()
 {
     $model = new Link();
     if (isset($_POST['Link'])) {
         $model->attributes = $_POST['Link'];
         $model->logo = isset($_POST['logo']) ? $_POST['logo'] : '';
         if ($model->save()) {
             $this->controller->message('success', Yii::t('admin', 'Add Success'), $this->controller->createUrl('index'));
         }
     }
     $this->controller->render('create', array('model' => $model));
 }
    public function sendCampaign()
    {
        // get abandoned cart :
        $sql = "SELECT * FROM (\n\t\tSELECT\n\t\tCONCAT(LEFT(c.`firstname`, 1), '. ', c.`lastname`) `customer`, a.id_cart total, ca.name carrier, c.id_customer, a.id_cart, a.date_upd,a.date_add,\n\t\t\t\tIF (IFNULL(o.id_order, 'Non ordered') = 'Non ordered', IF(TIME_TO_SEC(TIMEDIFF('" . date('Y-m-d H:i:s') . "', a.`date_add`)) > 86400, 'Abandoned cart', 'Non ordered'), o.id_order) id_order, IF(o.id_order, 1, 0) badge_success, IF(o.id_order, 0, 1) badge_danger, IF(co.id_guest, 1, 0) id_guest\n\t\tFROM `" . _DB_PREFIX_ . "cart` a  \n\t\t\t\tJOIN `" . _DB_PREFIX_ . "customer` c ON (c.id_customer = a.id_customer)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "currency` cu ON (cu.id_currency = a.id_currency)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "carrier` ca ON (ca.id_carrier = a.id_carrier)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "orders` o ON (o.id_cart = a.id_cart)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "connections` co ON (a.id_guest = co.id_guest AND TIME_TO_SEC(TIMEDIFF('" . date('Y-m-d H:i:s') . "', co.`date_add`)) < 1800)\n\t\t) AS toto WHERE id_order='Abandoned cart'";
        $currency = Context::getContext()->currency->sign;
        $defaultLanguage = new Language((int) Configuration::get('PS_LANG_DEFAULT'));
        $abandoned_carts = Db::getInstance()->ExecuteS($sql);
        // get all available campaigns
        $sqlCampaigns = 'SELECT * FROM `' . _DB_PREFIX_ . 'campaign` WHERE active=1';
        $allCampaigns = Db::getInstance()->ExecuteS($sqlCampaigns);
        // loop on all abandoned carts
        foreach ($abandoned_carts as $abncart) {
            // loop on all available campaigns
            foreach ($allCampaigns as $camp) {
                $cartIsOnCampaign = $this->checkIfCartIsOnCampaign($abncart['date_add'], $camp['execution_time_day'], $camp['execution_time_hour']);
                if ($cartIsOnCampaign) {
                    $id_lang = (int) Configuration::get('PS_LANG_DEFAULT');
                    $customer = new Customer($abncart['id_customer']);
                    $cR = new CartRule($camp['id_voucher'], $id_lang);
                    $cart = new Cart($abncart['id_cart']);
                    $products = $cart->getProducts();
                    $campM = new Campaign($camp['id_campaign']);
                    if (!empty($products)) {
                        $cart_content = $campM->getCartContentHeader();
                    } else {
                        $cart_content = '';
                    }
                    foreach ($products as $prod) {
                        $p = new Product($prod['id_product'], true, $id_lang);
                        $price_no_tax = Product::getPriceStatic($p->id, false, null, 2, null, false, true, 1, false, null, $abncart['id_cart'], null, $null, true, true, null, false, false);
                        $total_no_tax = $prod['cart_quantity'] * $price_no_tax;
                        $images = Image::getImages((int) $id_lang, (int) $p->id);
                        $link = new Link();
                        $cart_content .= '<tr >
										<td align="center" ><img src="' . $link->getImageLink($p->link_rewrite, $images[0]['id_image']) . '" width="80"/></td>
										<td align="center" ><a href="' . $link->getProductLink($p) . '"/>' . $p->name . '</a></td>
										<td align="center" >' . Tools::displayprice($price_no_tax) . '</td>
										<td align="center" >' . $prod['cart_quantity'] . '</td>
										<td align="center" >' . Tools::displayprice($total_no_tax) . '</td>
									</tr>';
                    }
                    $tpl_vars = array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{coupon_name}' => $cR->name, '{coupon_code}' => $cR->code, '{cart_content}' => $cart_content, '{coupon_value}' => $camp['voucher_amount_type'] == 'percent' ? $cR->reduction_percent . '%' : $currency . $cR->reduction_amount, '{coupon_valid_to}' => date('d/m/Y', strtotime($cR->date_to)), '{campaign_name}' => $camp['name']);
                    $path = _PS_ROOT_DIR_ . '/modules/superabandonedcart/mails/';
                    // send email to customer :
                    Mail::Send($id_lang, $campM->getFileName(), $camp['name'], $tpl_vars, $customer->email, null, null, null, null, null, $path, false, Context::getContext()->shop->id);
                    // Email to admin :
                    Mail::Send($id_lang, $campM->getFileName(), Mail::l(sprintf('Email sent to %s %s for campaign %s', $customer->lastname, $customer->firstname, $camp['name'])), $tpl_vars, Configuration::get('PS_SHOP_EMAIL'), null, null, null, null, null, $path, false, Context::getContext()->shop->id);
                    //	echo 'ID ' . $abncart['id_cart'];
                }
            }
        }
    }
 private function formatInternalMethod(Link $link)
 {
     if (empty($this->scope->class)) {
         return;
     }
     $methodName = substr($link->getDestination(), 0, strlen($link->getDestination()) - 2);
     $methods = $this->scope->class->getMethods(true);
     if (empty($methodName) || !array_key_exists($methodName, $methods)) {
         return;
     }
     $linkToClass = $this->getLinkToApiClass($this->scope->class->getName());
     return sprintf('[%s](%s#%s)', $link->getDescription(), $linkToClass, strtolower($methodName));
 }
Example #26
0
 public function testSaveProductRelations()
 {
     $data = [1];
     $typeId = 1;
     $this->model->setData('link_type_id', $typeId);
     $product = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->setMethods(['getRelatedLinkData', 'getUpSellLinkData', 'getCrossSellLinkData', '__wakeup'])->getMock();
     $product->expects($this->any())->method('getRelatedLinkData')->will($this->returnValue($data));
     $product->expects($this->any())->method('getUpSellLinkData')->will($this->returnValue($data));
     $product->expects($this->any())->method('getCrossSellLinkData')->will($this->returnValue($data));
     $map = [[$product, $data, Link::LINK_TYPE_RELATED, $this->resource], [$product, $data, Link::LINK_TYPE_UPSELL, $this->resource], [$product, $data, Link::LINK_TYPE_CROSSSELL, $this->resource]];
     $this->resource->expects($this->any())->method('saveProductLinks')->will($this->returnValueMap($map));
     $this->model->saveProductRelations($product);
 }
 private function formatInternalProperty(Link $link)
 {
     if (empty($this->scope->class)) {
         return;
     }
     $properties = $this->scope->class->getProperties(true);
     $propertyName = substr($link->getDestination(), 1);
     if (!$propertyName || !array_key_exists($propertyName, $properties)) {
         return;
     }
     $linkToClass = $this->getLinkToApiClass($this->scope->class->getName());
     return sprintf('[%s](%s#$%s)', $link->getDescription(), $linkToClass, strtolower($propertyName));
 }
Example #28
0
 /**
  * 录入
  *
  */
 public function actionCreate()
 {
     parent::_acl('link_create');
     $model = new Link();
     if (isset($_POST['Link'])) {
         $model->attributes = $_POST['Link'];
         if ($model->save()) {
             AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入友情链接,ID:' . $model->id));
             $this->redirect(array('index'));
         }
     }
     $this->render('create', array('model' => $model));
 }
 protected function formatProduct($id_product, $id_lang)
 {
     $link = new Link();
     $product = new Product($id_product, true, $id_lang);
     $category = new Category($product->id_category_default, $id_lang);
     $product->objectID = $product->id;
     $product->category = $category->name;
     $product->url = $link->getProductLink($product->id);
     /* Cover */
     $cover = Image::getCover($product->id);
     $product->image_link_small = $link->getImageLink($product->link_rewrite, $cover['id_image'], ImageType::getFormatedName('small'));
     $product->image_link_large = $link->getImageLink($product->link_rewrite, $cover['id_image'], ImageType::getFormatedName('large'));
     return $product;
 }
Example #30
0
File: Links.php Project: Joal01/fof
 /**
  * Add a single link to the links collection
  *
  * @param   string   $rel        The relation of the link to the document. See RFC 5988
  *                               http://tools.ietf.org/html/rfc5988#section-6.2.2 A document
  *                               MUST always have a "self" link.
  * @param   Link     $link       The actual link object
  * @param   boolean  $overwrite  When false and a link of $rel relation exists, an array of
  *                               links is created. Otherwise the existing link is overwriten
  *                               with the new one
  *
  * @return  boolean  True if the link was added to the collection
  */
 public function addLink($rel, Link $link, $overwrite = true)
 {
     if (!$link->check()) {
         return false;
     }
     if (!array_key_exists($rel, $this->_links) || $overwrite) {
         $this->_links[$rel] = $link;
     } else {
         if (!is_array($this->_links[$rel])) {
             $this->_links[$rel] = array($this->_links[$rel]);
         }
         $this->_links[$rel][] = $link;
     }
 }