public static function pkg_subscr_to_expirydate($pkg, $time = '')
 {
     if (!$time) {
         $time = time();
     }
     $expires = '';
     if (!is_array($pkg)) {
         return $expires;
     }
     if (!isset($pkg['subscr_num']) || !isset($pkg['subscr_type'])) {
         return $expires;
     }
     $type = $pkg['subscr_type'];
     switch ($type) {
         case 'month':
         case 'year':
             $type .= 's';
             $expires = strtotime("+{$pkg['subscr_num']} {$type}", $time);
             break;
         case 'none':
         default:
             $feu = cge_utils::get_module('FrontEndUsers');
             if ($feu) {
                 $timeperiod = $feu->GetPreference('expireage_months', 120);
                 $expires = strtotime("+{$timeperiod} months", $time);
             }
             break;
     }
     return $expires;
 }
 private static function lang()
 {
     if (!self::$__mod) {
         self::$__mod = \cge_utils::get_module('CGExtensions');
     }
     $args = func_get_args();
     return call_user_func_array(array(self::$__mod, 'Lang'), $args);
 }
 public static function create_template_dropdown($id, $name, $prefix = '', $selectedvalue = -1, $addtext = '')
 {
     $templates = self::get_templates_by_prefix('', $prefix);
     $items = array();
     foreach ($templates as $onename) {
         $tmp = substr($onename, strlen($prefix));
         $items[$tmp] = $onename;
     }
     return cge_utils::get_module()->CreateInputDropdown($id, $name, $items, -1, $selectedvalue, $addtext);
 }
 public static function &get_auth_consumer()
 {
     $res = null;
     $feu = cge_utils::get_module('FrontEndUsers');
     $name = $feu->GetPreference('auth_module', '');
     if ($name == '' || $name == '__BUILTIN__') {
         return self::get_std_consumer();
     }
     $module = cge_utils::get_module($name);
     if (!$module) {
         return $res;
     }
     $res = $module->GetFeuAuthConsumer();
     return $res;
 }
 public static function &get_instance($name)
 {
     return cge_utils::get_module($name);
 }
 public static function cge_admin_error($params, &$smarty)
 {
     global $CMS_ADMIN_PAGE;
     if (!isset($CMS_ADMIN_PAGE)) {
         return;
     }
     if (!isset($params['error'])) {
         return;
     }
     $mod = cge_utils::get_module('CGExtensions');
     $tmp = $mod->ShowErrors($params['error']);
     if (isset($params['assign'])) {
         $smarty->assign($params['assign'], $tmp);
         return;
     }
     return $tmp;
 }
 public static function expand_events($eventids, $returnid, $parameters, $limit = 10000, $startoffset = 0)
 {
     if (!is_array($eventids) || count($eventids) < 1) {
         return FALSE;
     }
     $module = cge_utils::get_module(MOD_CGCALENDAR);
     $gCms = CmsApp::get_instance();
     $db = $gCms->GetDb();
     $events_to_categories_table_name = $module->events_to_categories_table_name;
     $categories_table_name = $module->categories_table_name;
     $event_field_values_table_name = $module->event_field_values_table_name;
     $userops = $gCms->GetUserOperations();
     $tmp = $userops->LoadUsers();
     $users = array();
     foreach ($tmp as $oneuser) {
         $users[$oneuser->id] = $oneuser;
     }
     $query = 'SELECT * FROM ' . $module->events_table_name . ' WHERE event_id IN (' . implode(',', $eventids) . ')
               ORDER BY event_date_start ASC';
     $rs = $db->SelectLimit($query, $limit, $startoffset);
     $feu_users = array();
     while (!$rs->EOF()) {
         $row = $rs->fields;
         $uid = $row['event_created_by'];
         if ($uid < 1 && !in_array($uid, $feu_users)) {
             $feu_users[] = $uid;
         }
         $rs->MoveNext();
     }
     debug_display($feu_users);
     die;
     $rs->MoveFirst();
     $events = array();
     while ($rs && ($row = $rs->FetchRow())) {
         $titleSEO = munge_string_to_url($row['event_title']);
         $destpage = $module->GetPreference('defaultcalendarpage', -1);
         $destpage = $destpage > 0 ? $destpage : $returnid;
         //$destpage =$detailpage!=''?$detailpage:$destpage;
         $prefix = $module->GetPreference('url_prefix');
         if (!$prefix) {
             $prefix = 'calendar';
         }
         $prettyurl = sprintf($prefix . "/%d/%d-%s", $destpage, $row['event_id'], $titleSEO);
         $parms = array();
         $parms['event_id'] = $row['event_id'];
         $parms['display'] = 'event';
         if (isset($parameters['eventtemplate'])) {
             $parms['eventtemplate'] = $parameters['eventtemplate'];
         }
         $url = $module->CreateLink('cntnt01', 'default', $destpage, $contents = '', $parms, '', true, '', '', '', $prettyurl);
         $row['url'] = $url;
         $row['author'] = $users[$row['event_created_by']]->username;
         $row['authorname'] = $users[$row['event_created_by']]->firstname . ' ' . $users[$row['event_created_by']]->lastname;
         // Build the sql to retrieve the categories for this event.
         $sql = "SELECT category_name FROM {$events_to_categories_table_name}\n\t        INNER JOIN {$categories_table_name} ON  {$events_to_categories_table_name}.category_id = {$categories_table_name}.category_id\n\t        WHERE event_id = ?";
         $crs = $db->Execute($sql, array($row['event_id']));
         // Get the field values
         $categories = array();
         $categories_temp = array();
         if ($crs) {
             // make sure there are results and assign to the $categories array
             $categories_temp = $crs->GetArray();
             foreach ($categories_temp as $category) {
                 $category_name = $category['category_name'];
                 $categories[$category_name] = '1';
             }
         }
         // Attach the custom fields to the event
         $row['categories'] = $categories;
         // Build the sql to retrieve the field values for this event.
         $sql = "SELECT field_name,field_value FROM {$event_field_values_table_name} WHERE event_id = ?";
         $frs = $db->Execute($sql, array($row['event_id']));
         // Get the field values
         $fields = array();
         $fields_temp = array();
         if ($frs) {
             // make sure there are results and assign to the $fields array
             $fields_temp = $frs->GetArray();
             foreach ($fields_temp as $field) {
                 $field_name = $field['field_name'];
                 $field_value = $field['field_value'];
                 $fields[$field_name] = $field_value;
             }
         }
         // Attach the custom fields to the event
         $row['fields'] = $fields;
         // End custom fields retrieval
         // and add it to the list of completed, expanded events.
         $events[] = $row;
     }
     if ($rs) {
         $rs->Close();
     }
     return $events;
 }
 public static function redirect_with_error($returnid, $message, $error = 1)
 {
     $mod = cge_utils::get_module();
     $mod->Redirect($id, 'showmessage', $returnid, array('cge_msg' => $message, 'cge_error' => (int) $error));
 }
$smarty->assign('hidden_field_color', $this->GetPreference('hidden_field_color', 'green'));
$smarty->assign('secure_field_marker', $this->GetPreference('secure_field_marker', '^^'));
$smarty->assign('secure_field_color', $this->GetPreference('secure_field_color', 'yellow'));
$smarty->assign('pageidforgotpasswd', $this->GetPreference('pageidforgotpasswd'));
$smarty->assign('pageid_changesettings', $this->GetPreference('pageid_changesettings'));
$smarty->assign('pageid_login', $this->GetPreference('pageid_login'));
$smarty->assign('pageid_logout', $this->GetPreference('pageid_logout'));
$smarty->assign('pageid_afterverify', $this->GetPreference('pageid_afterverify'));
$smarty->assign('pageid_afterchangesettings', $this->GetPreference('pageid_afterchangesettings'));
// Get the number of users installed in FEU.
$query = 'SELECT count(id) FROM ' . cms_db_prefix() . 'module_feusers_users';
$db = cmsms()->GetDb();
$nusers = $db->GetOne($query);
$smarty->assign('total_user_count', $nusers);
$smarty->assign('pwsalt', $this->GetPreference('pwsalt'));
$cgecom = cge_utils::get_module('CGEcommerceBase');
$selfreg = cge_utils::get_module('SelfRegistration');
if ($cgecom && $selfreg && $selfreg->GetPreference('allowpaidregistration')) {
    $opts = array();
    $opts['none'] = $this->Lang('none');
    $opts['delete'] = $this->Lang('delete_user');
    $opts['expire'] = $this->Lang('expire_user');
    $smarty->assign('ecommerce_actions', $opts);
    $smarty->assign('ecomm_ordercancelled', $this->GetPreference('ecomm_ordercancelled', 'none'));
    $smarty->assign('ecomm_orderdeleted', $this->GetPreference('ecomm_orderdeleted', 'none'));
    $smarty->assign('ecomm_paidregistration', $this->GetPreference('ecomm_paidregistration', 0));
}
echo $this->ProcessTemplate('admin_authtab.tpl');
#
# EOF
#
 public static function cge_pageoptions($params, $smarty)
 {
     $current = trim(cge_utils::get_param($params, 'value'));
     $current = trim(cge_utils::get_param($params, 'selected'));
     $none = cge_utils::to_bool(cge_utils::get_param($params, 'none'));
     $params['current'] = $current;
     unset($params['value'], $params['selected'], $params['none']);
     $builder = new \CGExtensions\content_list_builder($params);
     $tmp = null;
     if ($none) {
         $mod = cge_utils::get_module(MOD_CGEXTENSIONS);
         $tmp .= '<option value="">' . $mod->Lang('none') . '</option>';
         $tmp .= '<option disabled="disabled">---</option>';
     }
     $tmp .= $builder->get_options();
     return $tmp;
 }
 /**
  * A function to provide a form to edit a single template.  Provides restore
  * to factory default settings as well.
  *
  * @param object  The module that this template is for.
  * @param string  The module action id.
  * @param integer The returnid (usually empty)
  * @param string  The template name
  * @param string  The active tab name
  * @param string  A title for the form, usually indicates which template this form is editing.
  * @param string  The filename (relative to the modules templates directory) of the factory default template source.
  * @param string  Optional help for this template
  * @param string  The destination action (usually defaultadmin)
  * @return string An HTML form
  */
 public static function get_single_template_form(&$module, $id, $returnid, $tmplname, $active_tab, $title, $filename, $info = '', $destaction = 'defaultadmin')
 {
     $cgextensions =& cge_utils::get_module('CGExtensions');
     $smarty =& $module->smarty;
     $smarty->assign('defaulttemplateform_title', $title);
     $smarty->assign('info_title', $info);
     $smarty->assign('startform', $cgextensions->CreateFormStart($id, 'setdefaulttemplate', $returnid, 'post', '', false, '', array('prefname' => $tmplname, 'usetemplate' => '1', 'destmodule' => $module->GetName(), 'cg_activetab' => $active_tab, 'destaction' => $destaction, 'filename' => $filename)));
     $smarty->assign('prompt_template', $cgextensions->Lang('template'));
     $smarty->assign('input_template', $cgextensions->CreateTextArea(false, $id, $module->GetTemplate($tmplname), 'input_template'));
     $smarty->assign('submit', $cgextensions->CreateInputSubmit($id, 'submit', $cgextensions->Lang('submit')));
     $smarty->assign('reset', $cgextensions->CreateInputSubmit($id, 'resettodefault', $cgextensions->Lang('resettofactory')));
     $smarty->assign('endform', $cgextensions->CreateFormEnd());
     return $cgextensions->ProcessTemplate('editdefaulttemplate.tpl');
 }
 private function _build_queries()
 {
     if ($this->_qrecs != '') {
         return;
     }
     if ($this->_qcount != '') {
         return;
     }
     if (!$this->count_opts()) {
         throw new Exception('invalid value');
     }
     $where = array();
     $qparms = array();
     $joins = array();
     $jcount = 0;
     foreach ($this->_and_opts as &$opt) {
         switch ($opt->get_type()) {
             case feu_user_query_opt::MATCH_USERNAME:
                 $where[] = 'u.username LIKE ?';
                 $qparms[] = str_replace('*', '%', $opt->get_expr());
                 break;
             case feu_user_query_opt::MATCH_PASSWORD:
                 $where[] = 'u.password = ?';
                 $qparms[] = $opt->get_expr();
                 break;
             case feu_user_query_opt::MATCH_EXPIRES_LT:
                 $tmp = $db->DbTimeStamp($opt->get_expr());
                 $where[] = "u.expires < {$tmp}";
                 break;
             case feu_user_query_opt::MATCH_GROUP:
                 $tmp = $this->_get_groups();
                 if (!isset($tmp[$opt->get_expr()])) {
                     throw new Exception('invalid value');
                 }
                 $joins = 'LEFT JOIN ' . cms_db_prefix() . 'module_feusers_belongs bl ON u.id = bl.userid';
                 $where[] = 'bl.groupid = ?';
                 $qparms[] = $opt->get_expr();
                 break;
             case feu_user_query_opt::MATCH_GROUPID:
                 $joins = 'LEFT JOIN ' . cms_db_prefix() . 'module_feusers_belongs bl ON u.id = bl.userid';
                 $where[] = 'bl.groupid = ?';
                 $qparms[] = $opt->get_expr();
                 break;
             case feu_user_query_opt::MATCH_PROPERTY:
                 $feu = cge_utils::get_module('FrontEndUsers');
                 $defns = $feu->GetPropertyDefns();
                 if (!in_array($opt->get_expr(), array_keys($defns))) {
                     throw new Exception('invalid value');
                 }
                 $jcount++;
                 $joins[] = 'LEFT JOIN ' . cms_db_prefix() . "module_feusers_properties pr{$jcount} \n                        ON pr{$jcount}.userid = u.id \n                       AND pr{$jcount}.title = '" . $opt->get_expr() . "'";
                 if (strstr($opt->get_opt(), '*') === FALSE) {
                     $where[] = "pr{$jcount}.data = '" . $opt->get_opt() . "'";
                 } else {
                     $where[] = "pr{$jcount}.data LIKE '" . str_replace('*', '%', $opt->get_opt()) . "'";
                 }
                 break;
         }
     }
     // asembly
     $qrec = 'SELECT u.id FROM ' . cms_db_prefix() . 'module_feusers_users u';
     $qcnt = 'SELECT count(u.id) AS count FROM ' . cms_db_prefix() . 'module_feusers_users u';
     if (count($joins)) {
         $qrec .= ' ' . implode(' ', $joins);
         $qcnt .= ' ' . implode(' ', $joins);
     }
     if (count($where)) {
         $qrec .= "\nWHERE " . implode(' AND ', $where);
         $qcnt .= "\nWHERE " . implode(' AND ', $where);
     }
     $this->_qrecs = $qrec;
     $this->_qcount = $qcnt;
     $this->_qparms = $qparms;
     return;
 }
 /**
  * A function to provide a form to edit a single template.  Provides restore
  * to factory default settings as well.
  *
  * @param CMSModule $module The module that this template is for.
  * @param string  $id The module action id.
  * @param int     $returnid The returnid (usually empty)
  * @param string  $tmplname The template name
  * @param string  $active_tab The active tab name
  * @param string  $title A title for the form, usually indicates which template this form is editing.
  * @param string  $filename The filename (relative to the modules templates directory) of the factory default template source.
  * @param string  $info Optional help for this template
  * @param string  $destaction The destination action (usually defaultadmin)
  * @param bool    $simple whether to output a simple form
  * @return string An HTML form
  */
 public static function get_single_template_form(&$module, $id, $returnid, $tmplname, $active_tab, $title, $filename, $info = '', $destaction = 'defaultadmin', $simple = 0)
 {
     $cgextensions = cge_utils::get_module(MOD_CGEXTENSIONS);
     $tpl = $cgextensions->CreateSmartyTemplate('editdefaulttemplate.tpl');
     $title = trim($title);
     if ($title) {
         $tpl->assign('defaulttemplateform_title', $title);
     }
     $tpl->assign('mod', $module);
     $tpl->assign('prefname', $tmplname);
     $tpl->assign('info_title', $info);
     $tpl->assign('startform', $cgextensions->CreateFormStart($id, 'setdefaulttemplate', $returnid, 'post', '', false, '', array('prefname' => $tmplname, 'usetemplate' => '1', 'destmodule' => $module->GetName(), 'cg_activetab' => $active_tab, 'destaction' => $destaction, 'filename' => $filename)));
     $tpl->assign('prompt_template', $cgextensions->Lang('template'));
     $tpl->assign('input_template', $cgextensions->CreateTextArea(false, $id, $module->GetTemplate($tmplname), 'input_template'));
     $tpl->assign('simple', $simple);
     $tpl->assign('submit', $cgextensions->CreateInputSubmit($id, 'submit', $cgextensions->Lang('submit')));
     $tpl->assign('reset', $cgextensions->CreateInputSubmit($id, 'resettodefault', $cgextensions->Lang('resettofactory')));
     $tpl->assign('endform', $module->CreateFormEnd());
     return $tpl->fetch();
 }
$policies['none'] = $this->Lang('policy_none');
$policies['individual'] = $this->Lang('policy_individual');
$smarty->assign('overlap_policies', $policies);
$smarty->assign('overlap_policy', $this->GetPreference('overlap_policy', 'all'));
$overlap_actions = array();
$overlap_actions['remove'] = $this->Lang('overlap_action_remove');
$overlap_actions['error'] = $this->Lang('overlap_action_error');
$smarty->assign('overlap_actions', $overlap_actions);
$smarty->assign('overlap_action', $this->GetPreference('overlap_action', 'error'));
$prefix = $this->GetPreference('url_prefix');
if (!$prefix) {
    $prefix = 'calendar';
}
$smarty->assign('url_prefix', $prefix);
$smarty->assign('dflt_starttime', $this->GetPreference('dflt_starttime', '12:00'));
$smarty->assign('dflt_alldayevent', $this->GetPreference('dflt_alldayevent', 0));
$smarty->assign('firstdayofweek', $this->GetPreference('firstdayofweek', 1));
$smarty->assign('dayoptions', array(0 => $this->Lang('sunday'), 1 => $this->Lang('monday')));
$smarty->assign('ical_holidays', $this->GetPreference('ical_holidays'));
$smarty->assign('holiday_fgcolor', $this->GetPreference('holiday_fgcolor', '#000000'));
$smarty->assign('holiday_bgcolor', $this->GetPreference('holiday_bgcolor', '#ccffff7'));
$smarty->assign('submit', $this->CreateInputSubmit($id, 'submit', $this->Lang('cal_updatesettings')));
$feu = cge_utils::get_module('FrontEndUsers');
if ($feu) {
    $tmp = $feu->GetGroupList();
    $tmp = cge_array::hash_prepend($tmp, $this->Lang('none'), -1);
    $smarty->assign('grouplist', array_flip($tmp));
    $smarty->assign('frontend_group', $this->GetPreference('frontend_group', -1));
}
echo $this->ProcessTemplate('settings.tpl');
// EOF
 public function is_authenticated()
 {
     $mod = cge_utils::get_module('FrontEndUsers');
     $mod->_AttemptLoginWithCookie();
     return $mod->LoggedIn();
 }