public function index()
 {
     $perPage = 10;
     $expiredEvents = $this->eventRepository->getPastEvents($perPage);
     //find countries,authors,and categories to display in search form
     $countries = [0 => trans('word.choose_country')] + $this->countryRepository->getAll()->lists('name_' . getLocale(), 'id');
     $categories = [0 => trans('word.choose_category')] + $this->categoryRepository->getEventCategories()->lists('name_' . getLocale(), 'id');
     $authors = [0 => trans('word.choose_author')] + $this->userRepository->getRoleByName('author')->lists('name_' . getLocale(), 'id');
     // find selected form values
     $search = trim(Input::get('search'));
     $category = Request::get('category');
     $author = Request::get('author');
     $country = Request::get('country');
     $expired = Request::get('past');
     $this->title = trans('word.events');
     // if the form is selected
     // perform search
     if (!empty($search) || !empty($category) || !empty($author) || !empty($country)) {
         $events = $this->eventRepository->getAll()->where(function ($query) use($search, $category, $author, $country) {
             if (!empty($search)) {
                 $query->where('title_ar', 'LIKE', "%{$search}%")->orWhere('title_en', 'LIKE', "%{$search}%");
             }
             if (!empty($category)) {
                 $query->where('category_id', $category);
             }
             if (!empty($author)) {
                 $query->where('user_id', $author);
             }
             if (!empty($country)) {
                 $locations = $this->countryRepository->findById($country)->locations()->lists('id');
                 $query->whereIn('location_id', $locations);
             }
         })->orderBy('date_start', 'ASC')->orderBy('created_at', 'ASC')->paginate($perPage);
     } elseif (isset($expired) && $expired == 'true') {
         // Past Events
         $this->title = trans('word.expired_events');
         $events = $expiredEvents;
     } else {
         $events = $this->eventRepository->getNonExpiredEvents($perPage);
     }
     $eventCategories = $this->categoryRepository->getEventCategories()->get();
     $tags = $this->tagRepository->getEventTags();
     $this->render('site.events.index', compact('events', 'authors', 'categories', 'countries', 'search', 'category', 'author', 'country', 'eventCategories', 'tags', 'expiredEvents'));
 }
Exemple #2
0
 public function blogTags()
 {
     return DB::table('tags')->select(['tags.id', 'tags.name_' . getLocale() . ' as name'])->leftJoin('taggables', 'tags.id', '=', 'taggables.tag_id')->where('taggables.taggable_type', 'Blog')->groupBy('tags.id')->get();
 }
Exemple #3
0
function civicrm_api3_speakcivi_sendconfirm($params)
{
    $confirmationBlock = $params['confirmation_block'];
    $contactId = $params['contact_id'];
    $campaignId = $params['campaign_id'];
    $activityId = $params['activity_id'];
    $campaignObj = new CRM_Speakcivi_Logic_Campaign($campaignId);
    $locale = $campaignObj->getLanguage();
    $params['from'] = $campaignObj->getSenderMail();
    $params['format'] = null;
    if ($confirmationBlock) {
        $params['subject'] = $campaignObj->getSubjectNew();
        $message = $campaignObj->getMessageNew();
    } else {
        $params['subject'] = $campaignObj->getSubjectCurrent();
        $message = $campaignObj->getMessageCurrent();
    }
    if (!$message) {
        if ($confirmationBlock) {
            $message = CRM_Speakcivi_Tools_Dictionary::getMessageNew($locale);
            $campaignObj->setCustomFieldBySQL($campaignId, $campaignObj->fieldMessageNew, $message);
        } else {
            $message = CRM_Speakcivi_Tools_Dictionary::getMessageCurrent($locale);
            $campaignObj->setCustomFieldBySQL($campaignId, $campaignObj->fieldMessageCurrent, $message);
        }
    }
    $contact = array();
    $params_contact = array('id' => $contactId, 'sequential' => 1);
    $result = civicrm_api3('Contact', 'get', $params_contact);
    if ($result['count'] == 1) {
        $contact = $result['values'][0];
    }
    /* CONFIRMATION_BLOCK */
    $hash = sha1(CIVICRM_SITE_KEY . $contactId);
    $utm_content = 'version_' . $contactId % 2;
    $utm_campaign = $campaignObj->getUtmCampaign();
    $url_confirm_and_keep = CRM_Utils_System::url('civicrm/speakcivi/confirm', "id={$contactId}&aid={$activityId}&cid={$campaignId}&hash={$hash}&utm_source=civicrm&utm_medium=email&utm_campaign={$utm_campaign}&utm_content={$utm_content}", true);
    $url_confirm_and_not_receive = CRM_Utils_System::url('civicrm/speakcivi/optout', "id={$contactId}&aid={$activityId}&cid={$campaignId}&hash={$hash}&utm_source=civicrm&utm_medium=email&utm_campaign={$utm_campaign}&utm_content={$utm_content}", true);
    $template = CRM_Core_Smarty::singleton();
    $template->assign('url_confirm_and_keep', $url_confirm_and_keep);
    $template->assign('url_confirm_and_not_receive', $url_confirm_and_not_receive);
    $locales = getLocale($locale);
    $confirmation_block_html = $template->fetch('../templates/CRM/Speakcivi/Page/ConfirmationBlock.' . $locales['html'] . '.html.tpl');
    $confirmation_block_text = $template->fetch('../templates/CRM/Speakcivi/Page/ConfirmationBlock.' . $locales['text'] . '.text.tpl');
    /* SHARING_BLOCK */
    $template->clearTemplateVars();
    $template->assign('url_campaign', $campaignObj->getUrlCampaign());
    $template->assign('url_campaign_fb', prepareCleanUrl($campaignObj->getUrlCampaign()));
    $template->assign('utm_campaign', $campaignObj->getUtmCampaign());
    $template->assign('share_facebook', CRM_Speakcivi_Tools_Dictionary::getShareFacebook($locale));
    $template->assign('share_twitter', CRM_Speakcivi_Tools_Dictionary::getShareTwitter($locale));
    $template->assign('twitter_share_text', urlencode($campaignObj->getTwitterShareText()));
    $sharing_block_html = $template->fetch('../templates/CRM/Speakcivi/Page/SharingBlock.html.tpl');
    $template->clearTemplateVars();
    $template->assign('contact', $contact);
    $message = $template->fetch('string:' . $message);
    $message_html = str_replace("#CONFIRMATION_BLOCK", html_entity_decode($confirmation_block_html), $message);
    $message_text = str_replace("#CONFIRMATION_BLOCK", html_entity_decode($confirmation_block_text), $message);
    $message_html = str_replace("#SHARING_BLOCK", html_entity_decode($sharing_block_html), $message_html);
    $message_text = str_replace("#SHARING_BLOCK", html_entity_decode($sharing_block_html), $message_text);
    $params['html'] = $message_html;
    $params['text'] = convertHtmlToText($message_text);
    $sent = CRM_Utils_Mail::send($params);
    return civicrm_api3_create_success($sent, $params);
}
Exemple #4
0
 public function getSQLFields($data, array &$fields, array &$values)
 {
     $oldLocale = getLocale();
     setLocale(LC_ALL, 'C');
     $db = ezcDbInstance::get();
     foreach ($this->fields as $key => $field) {
         $default = isset($field['default']) ? $field['default'] : null;
         if (isset($field['is_primary_key']) && $field['is_primary_key'] === true) {
             continue;
             // ignore primary key
         }
         if (isset($field['calculated']) && $field['calculated'] === true) {
             continue;
             // ignore primary key
         }
         if (isset($field['name'])) {
             $key = $field['name'];
         }
         $fields[] = $key;
         if (isset($field['value'])) {
             $values[] = $db->quote($field['value']);
         } else {
             if ($field['type'] == 'NOW') {
                 $values[] = 'now()';
             } else {
                 if ($field['type'] == 'UID') {
                     $values[] = $this->auth->getUID();
                 } else {
                     if (isset($data[$key])) {
                         $values[] = $this->prepareFieldValue($this->act, $key, $data[$key], $field['type'], isset($field['size']) ? $field['size'] : null, $default);
                     } else {
                         $values[] = $this->prepareFieldValue($this->act, $key, null, $field['type'], isset($field['size']) ? $field['size'] : null, $default);
                     }
                 }
             }
         }
     }
     setLocale(LC_ALL, $oldLocale);
 }
Exemple #5
0
/**
 * set the locale informations. The changed information are affected only by the library functions
 *
 * @param array     the value to change
 * @param mixed     locale code (eg: en_EN.utf8) or null. If null the current locale is used
 * @return boolean  return true on success
 * @see localeconv
 */
function setLocaleInfo($data, $locale = null)
{
    global $localeInfoTable;
    if ($locale === null) {
        $locale = getLocale();
    }
    if (!isset($localeInfoTable[$locale])) {
        /* Load the locale data */
        if (!getLocaleInfo($locale)) {
            return false;
            /* function faild: Locale not found */
        }
    }
    foreach ($data as $key => $val) {
        $localeInfoTable[$locale][$key] = $val;
    }
    return true;
}
Exemple #6
0
 /**
  * Ajax request to submit data
  * @param array $request   the request
  * @return array           ajax format status
  */
 public function submitFormData($request)
 {
     $errors = array();
     $db = ezcDbInstance::get();
     $request['us_id'] = (int) $request['id'];
     $request['do_id'] = $this->do_id;
     if ($this->act != 'del') {
         $errors = $this->checkFormData($request);
     }
     if (count($errors) > 0) {
         return $this->getAjaxErrorResult($errors);
     } else {
         $oldLocale = getLocale();
         setLocale(LC_ALL, 'C');
         $db->beginTransaction();
         $oldIds = R3EcoGisUtilityHelper::getProductId($request['us_id']);
         if ($this->act == 'del') {
             // Cancella comuni vecchi
             R3EcoGisUtilityHelper::setMunicipality($request['us_id'], array());
             foreach ($db->query("SELECT up_id FROM utility_product WHERE us_id=" . (int) $request['us_id']) as $row) {
                 R3EcoGisUtilityHelper::deleteProduct(array('up_id' => $row['up_id']));
             }
         }
         $id = $this->applyData($request);
         $newIds = array(0, 1, 2);
         // valori nuovo
         $cantDelete = 'F';
         if ($this->act == 'add' || $this->act == 'mod') {
             $order = 0;
             R3EcoGisUtilityHelper::setMunicipality($id, explode(',', $request['municipality']));
             // Modifica valori vecchi
             foreach ($oldIds as $up_id) {
                 $order += 10;
                 if (isset($request["up_name_1_{$up_id}"]) && $request["up_name_1_{$up_id}"] != '') {
                     R3EcoGisUtilityHelper::updateProduct(array('up_id' => $up_id, 'up_name_1' => $request["up_name_1_{$up_id}"], 'up_name_2' => @$request["up_name_2_{$up_id}"], 'esu_co2_factor' => $request["esu_co2_factor_{$up_id}"], 'ges_id' => $request["ges_id_{$up_id}"], 'up_order' => $order));
                 } else {
                     try {
                         R3EcoGisUtilityHelper::deleteProduct(array('up_id' => $up_id));
                     } catch (Exception $e) {
                         $cantDelete = 'T';
                     }
                 }
             }
             // Aggiunge valori nuovi
             foreach ($newIds as $up_id) {
                 // echo $request["up_name_1_new_{$up_id}"];
                 $order += 10;
                 if (isset($request["up_name_1_new_{$up_id}"]) && $request["up_name_1_new_{$up_id}"] != '') {
                     R3EcoGisUtilityHelper::addProduct(array('do_id' => $this->do_id, 'us_id' => $id, 'up_name_1' => $request["up_name_1_new_{$up_id}"], 'up_name_2' => @$request["up_name_2_new_{$up_id}"], 'up_order' => $order, 'esu_co2_factor' => $request["esu_co2_factor_new_{$up_id}"], 'ges_id' => $request["ges_id_new_{$up_id}"], 'et_code' => $request["et_code_new_{$up_id}"]));
                 }
             }
         }
         $db->commit();
         R3EcoGisEventNotifier::notifyDataChanged($this, array('data_changed' => true));
         setLocale(LC_ALL, $oldLocale);
         return array('status' => R3_AJAX_NO_ERROR, 'js' => "submitFormDataUtilityDone({$id}, '{$cantDelete}')");
     }
 }
Exemple #7
0
<?php

require_once 'gettext.inc';
# REM: http://localhost/index.php?locale=en   will give you english
#      http://localhost/index.php?locale=fr   will give you french
$locale = getLocale();
// WORKAROUND : Windows hacks
putenv('LANGUAGE=' . $locale);
putenv('LANG=' . $locale);
putenv('LC_ALL=' . $locale);
putenv('LC_MESSAGES=' . $locale);
// END WORKAROUND
if ($locale === "fr") {
    // Try many values because OS doesn't have the same constants
    $phpLocale = setlocale(LC_ALL, "fr_FR", "fr", "fra", "French");
} elseif ($locale === "en") {
    // Try many values because OS doesn't have the same constants
    $phpLocale = setlocale(LC_ALL, "en_US", "us", "usa", "en", "eng", "English");
} elseif ($locale === "pt_BR") {
    // Try many values because OS doesn't have the same constants
    $phpLocale = setlocale(LC_ALL, "pt_BR", "pt", "Portuguese");
} elseif ($locale === "de_DE") {
    // Try many values because OS doesn't have the same constants
    $phpLocale = setlocale(LC_ALL, "de_DE", "de", "German");
} elseif ($locale === "it_IT") {
    // Try many values because OS doesn't have the same constants
    $phpLocale = setlocale(LC_ALL, "it_IT", "it", "Italian");
} else {
    // No locale set, it's because visitors modify the url, so forbidden reply
    header('HTTP/1.1 403 Forbidden');
    exit;
Exemple #8
0
            return array('en_US', 'en_US.utf8');
    }
}
function setLeBonMailLocale($locales)
{
    foreach ($locales as $locale) {
        if (setlocale(LC_ALL, $locale) !== false) {
            putenv('LC_ALL=' . $locale);
            break;
        }
    }
    bindtextdomain('messages', './locale');
    bind_textdomain_codeset('messages', 'UTF-8');
    textdomain('messages');
}
setLeBonMailLocale(getLocale());
//GET route
$app->get('/', 'register_form');
$app->get('/index', 'register_form');
$app->get('/remove/:hash', 'remove');
$app->post('/register', 'register');
$app->get('/email', 'email_test');
$app->get('/paid', 'paid');
$app->post('/ipn', 'ipn');
$app->get('/all_searches', function () use($app) {
    try {
        $db = new PDO($app->config('database'), $app->config('dbuser'), $app->config('dbpassword'));
        $q = "SELECT searches.* FROM searches HAVING searches.updated_at IS NULL  OR searches.updated_at < unix_timestamp(DATE_SUB(NOW(), INTERVAL 1 HOUR))";
        $stmt = $db->prepare($q);
        $p = array(date('Y-m-d H:i:s'));
        $stmt->execute($p);
Exemple #9
0
<?php 
tinclude('blocks/top_banner');
?>

<div class="title-l-1"><span><?php 
echo getLocale($top2Section);
?>
</span></div>
<div class="main-cont">
    <span class="label-t news-dat"><?php 
echo getNewsDate($CurrentNode);
?>
</span>
    <h2><?php 
echo getLocale($CurrentNode);
?>
</h2>
    <?php 
if (strlen($CurrentNode->tfields['photo']['thumburl'])) {
    ?>

        <div class="cont-gallery js-fancy">
            <a href="<?php 
    echo $CurrentNode->tfields['photo']['url'];
    ?>
" class="cont-img" data-fancybox-group="gallery-1" title="<?php 
    echo htmlspecialchars($CurrentNode->tfields['photo_alt']);
    ?>
">
                <img src="<?php 
Exemple #10
0
function civicrm_api3_speakcivi_remind($params)
{
    // how old not confirmed petitions
    $start = microtime(true);
    $days = $params['days'];
    $daysContact = $params['days_contact'];
    if ($daysContact < $days) {
        $daysContact = $days;
    }
    $groupId = CRM_Core_BAO_Setting::getItem('Speakcivi API Preferences', 'group_id');
    $activityTypeId = CRM_Core_OptionGroup::getValue('activity_type', 'Petition', 'name', 'String', 'value');
    $adminId = 1;
    $query = "SELECT acp.activity_id, ap.campaign_id, acp.contact_id\n            FROM civicrm_activity ap\n              JOIN civicrm_activity_contact acp ON acp.activity_id = ap.id\n              JOIN civicrm_contact c ON c.id = acp.contact_id\n              LEFT JOIN civicrm_group_contact gc ON gc.contact_id = acp.contact_id AND gc.group_id = %1 AND gc.status = 'Added'\n            WHERE ap.activity_type_id = %2 AND ap.status_id = 1 AND ap.activity_date_time <= date_add(current_date, INTERVAL -%3 DAY)\n                AND c.created_date >= date_add(current_date, INTERVAL -%4 DAY)\n                AND c.is_opt_out = 0 AND c.is_deleted = 0 AND c.is_deceased = 0 AND c.do_not_email = 0 AND gc.id IS NULL";
    $params = array(1 => array($groupId, 'Integer'), 2 => array($activityTypeId, 'Integer'), 3 => array($days, 'Integer'), 4 => array($daysContact, 'Integer'));
    $dao = CRM_Core_DAO::executeQuery($query, $params);
    $contacts = array();
    $campaigns = array();
    while ($dao->fetch()) {
        $contacts[$dao->campaign_id][$dao->contact_id] = $dao->contact_id;
        $campaigns[$dao->campaign_id] = $dao->campaign_id;
    }
    $message = array();
    $subject = array();
    $utmCampaign = array();
    $locale = array();
    $language = array();
    $email = array();
    foreach ($campaigns as $cid) {
        $campaignObj = new CRM_Speakcivi_Logic_Campaign($cid);
        $message[$cid] = $campaignObj->getMessageNew();
        $subject[$cid] = substr(removeSmartyIfClause(convertTokens($campaignObj->getSubjectNew())), 0, 128);
        $utmCampaign[$cid] = $campaignObj->getUtmCampaign();
        $locale[$cid] = $campaignObj->getLanguage();
        $language[$cid] = strtoupper(substr($locale[$cid], 0, 2));
        $email[$cid] = parseSenderEmail($campaignObj->getSenderMail());
    }
    // fetch confirmation block
    $messageHtml = array();
    $messageText = array();
    foreach ($message as $cid => $msg) {
        $url_confirm_and_keep = CRM_Utils_System::url('civicrm/speakcivi/confirm', null, true) . "?id={contact.contact_id}&cid={$cid}&hash={speakcivi.confirmation_hash}&utm_source=civicrm&utm_medium=email&utm_campaign=" . $utmCampaign[$cid];
        $url_confirm_and_not_receive = CRM_Utils_System::url('civicrm/speakcivi/optout', null, true) . "?id={contact.contact_id}&cid={$cid}&hash={speakcivi.confirmation_hash}&utm_source=civicrm&utm_medium=email&utm_campaign=" . $utmCampaign[$cid];
        $locales = getLocale($locale[$cid]);
        $confirmationBlockHtml = implode('', file(dirname(__FILE__) . '/../../templates/CRM/Speakcivi/Page/ConfirmationBlock.' . $locales['html'] . '.html.tpl'));
        $confirmationBlockText = implode('', file(dirname(__FILE__) . '/../../templates/CRM/Speakcivi/Page/ConfirmationBlock.' . $locales['text'] . '.text.tpl'));
        $confirmationBlockHtml = str_replace('{$url_confirm_and_keep}', $url_confirm_and_keep, $confirmationBlockHtml);
        $confirmationBlockHtml = str_replace('{$url_confirm_and_not_receive}', $url_confirm_and_not_receive, $confirmationBlockHtml);
        $confirmationBlockText = str_replace('{$url_confirm_and_keep}', $url_confirm_and_keep, $confirmationBlockText);
        $confirmationBlockText = str_replace('{$url_confirm_and_not_receive}', $url_confirm_and_not_receive, $confirmationBlockText);
        $messageHtml[$cid] = removeSmartyIfClause(convertTokens(removeDelim(str_replace("#CONFIRMATION_BLOCK", $confirmationBlockHtml, $msg))));
        $messageText[$cid] = convertHtmlToText(removeSmartyIfClause(convertTokens(removeDelim(str_replace("#CONFIRMATION_BLOCK", $confirmationBlockText, $msg)))));
    }
    foreach ($campaigns as $cid) {
        $sentContacts = findSentContacts($cid);
        $contacts[$cid] = excludeContacts($contacts[$cid], $sentContacts);
        if (is_array($contacts[$cid]) && count($contacts[$cid]) > 0) {
            if ($mailingId = findNotCompletedMailing($cid)) {
                if ($linkedGroupId = findLinkedGroup($mailingId)) {
                    addContactsToGroup($contacts[$cid], $linkedGroupId);
                } else {
                    $includeGroupId = createGroup($cid, $language[$cid]);
                    addContactsToGroup($contacts[$cid], $includeGroupId);
                    includeGroup($mailingId, $includeGroupId);
                }
            } else {
                $name = determineMailingName($cid, $language[$cid]);
                $params = array('name' => $name, 'subject' => $subject[$cid], 'body_text' => $messageText[$cid], 'body_html' => $messageHtml[$cid], 'created_id' => $adminId, 'created_date' => date('YmdHis'), 'campaign_id' => $cid, 'mailing_type' => 'standalone', 'unsubscribe_id' => 5, 'resubscribe_id' => 6, 'optout_id' => 7, 'reply_id' => 8, 'open_tracking' => 1, 'url_tracking' => 1, 'dedupe_email' => 1, 'from_name' => $email[$cid]['from_name'], 'from_email' => $email[$cid]['from_email'], 'footer_id' => chooseFooter($language[$cid]));
                $mailing = new CRM_Mailing_BAO_Mailing();
                $mm = $mailing->add($params);
                excludeGroup($mm->id, $groupId);
                if ($existingGroupId = findExistingGroup($cid)) {
                    cleanGroup($existingGroupId);
                    addContactsToGroup($contacts[$cid], $existingGroupId);
                    includeGroup($mm->id, $existingGroupId);
                } else {
                    $includeGroupId = createGroup($cid, $language[$cid]);
                    addContactsToGroup($contacts[$cid], $includeGroupId);
                    includeGroup($mm->id, $includeGroupId);
                }
            }
        }
    }
    $results = array('time' => microtime(true) - $start);
    return civicrm_api3_create_success($results, $params);
}
Exemple #11
0
<?php

session_start();
$settingsFile = trim(implode('', file('path.inc'))) . '/civicrm.settings.php';
define('CIVICRM_SETTINGS_PATH', $settingsFile);
$error = @(include_once $settingsFile);
if ($error == false) {
    echo "Could not load the settings file at: {$settingsFile}\n";
    exit;
}
// Load class loader
global $civicrm_root;
require_once $civicrm_root . '/CRM/Core/ClassLoader.php';
CRM_Core_ClassLoader::singleton()->register();
require_once 'CRM/Core/Config.php';
$config = CRM_Core_Config::singleton();
require_once 'api/v3/Speakcivi.php';
$locales = array('de_DE', 'el_GR', 'en_GB', 'es_ES', 'fr_FR', 'it_IT', 'pl_PL', 'sv_SE');
foreach ($locales as $locale) {
    $lc = getLocale($locale);
    echo "\n" . $locale . ": \n";
    print_r($lc);
}