public static function get_fielddefs()
 {
     if (cge_tmpdata::exists('cgfb_fielddefs')) {
         return cge_tmpdata::get('cgfb_fielddefs');
     }
     $db = cmsms()->GetDb();
     $query = 'SELECT * FROM ' . CGFEEDBACK_TABLE_FIELDDEFS . ' ORDER BY iorder';
     $tmp = $db->GetArray($query);
     if (is_array($tmp)) {
         for ($i = 0; $i < count($tmp); $i++) {
             $tmp[$i]['attribs'] = unserialize($tmp[$i]['attribs']);
             if (isset($tmp[$i]['attribs']['options'])) {
                 $t2 = cge_array::explode_with_key($tmp[$i]['attribs']['options'], '=', "\n");
                 $tmp[$i]['attribs']['options'] = array_flip($t2);
             }
         }
         $tmp = cge_array::to_hash($tmp, 'id');
         cge_tmpdata::set('cgfb_fielddefs', $tmp);
         return $tmp;
     }
 }
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Or read it online: http://www.gnu.org/licenses/licenses.html#GPL
#
#-------------------------------------------------------------------------
#END_LICENSE
// an order has been deleted.
if (!isset($params['order_id'])) {
    return;
}
// handle the case of attempted recursion.
if (cge_tmpdata::exists(__FILE__)) {
    return;
}
cge_tmpdata::set(__FILE__, 1);
// here we grab the order directly.
$order_id = (int) $params['order_id'];
$order_obj = orders_ops::load_by_id($order_id);
if (!$order_obj) {
    return;
}
// find the line item with a SelfReg Subscription.
for ($s = 0; $s < $order_obj->count_destinations(); $s++) {
    $shipping = $order_obj->get_shipping($s);
    for ($i = 0; $i < $shipping->count_all_items(); $i++) {
        $item = $shipping->get_item($i);
        if ($item->get_source() != 'SelfRegistration') {
            continue;
        }
        if ($item->get_item_type() != line_item::ITEMTYPE_SERVICE) {
 public static function cge_array_erase($params, &$smarty)
 {
     if (!isset($params['array']) || !isset($params['key'])) {
         // no params, do nothing.
         return;
     }
     $arr = trim($params['array']);
     $key = trim($params['key']);
     if ($arr == '' || $key == '') {
         return;
     }
     if (!cge_tmpdata::exists($arr)) {
         return;
     }
     $data = cge_tmpdata::get($arr);
     if (isset($data[$key])) {
         unset($data[$key]);
     }
     if (count(array_keys($data)) == 0) {
         cge_tmpdata::erase($arr);
         return;
     }
     cge_tmpdata::set($arr, $data);
 }
Exemplo n.º 4
0
 /**
  * A replacement for the built in DoAction method
  * For CGExtensions derived modules some  builtin smarty variables are created
  * module hints are handled,  and input type=image values are corrected in input parameters.
  *
  * this method also handles setting the active tab, and displaying any messages or errors
  * set with the SetError or SetMessage methods.
  *
  * This method is called automatically by the system based on the incoming request, and the page template.
  * It should almost never be called manually.
  *
  * @see SetError()
  * @see SetMessage()
  * @see SetCurrentTab()
  * @see RedirectToTab()
  * @param string $name the action name
  * @param string $id The module action id
  * @param array  $params The module parameters
  * @param int    $returnid  The page that will contain the HTML results.  This is empty for admin requests.
  */
 public function DoAction($name, $id, $params, $returnid = '')
 {
     if (!method_exists($this, 'set_action_id') && $this->GetName() != MOD_CGEXTENSIONS) {
         die('FATAL ERROR: A module derived from CGExtensions is not handling the set_action_id method');
     }
     $this->set_action_id($id);
     // handle the stupid input type='image' problem.
     foreach ($params as $key => $value) {
         if (endswith($key, '_x')) {
             $base = substr($key, 0, strlen($key) - 2);
             if (isset($params[$base . '_y']) && !isset($params[$base])) {
                 $params[$base] = $base;
             }
         }
     }
     // handle module hints
     $hints = cms_utils::get_app_data('__MODULE_HINT__' . $this->GetName());
     if (is_array($hints)) {
         foreach ($hints as $key => $value) {
             if (isset($params[$key])) {
                 continue;
             }
             $params[$key] = $value;
         }
     }
     /*
     if( !CmsApp::get_instance()->is_frontend_request() && $this->CheckPermission('Modify Modules') ) {
         // display module integrity stuff
         // only to people with appropriate permission, and only on admin requests
         // data is cached for one day (or until cache is cleared)
         $cge = \cms_utils::get_module(MOD_CGEXTENSIONS);
         $rec = \CGExtensions\internal\ModuleIntegrityTools::get_cached_status($this->GetName());
         switch( $rec['status'] ) {
         case -1: // no checksum stuff
             // only display this once per day
             if( !\cge_utils::done_today('module_sig'.$this->GetName()) ) {
                 $out = '<div class="cge_sig sig_error" title="'.$cge->Lang('info_vrfy_nodata').'"/>';
                 $out .= '<span>'.$rec['message'].'</span>';
                 $out .= '</div>';
                 $out .= '<div class="clearb"></div>';
                 echo $out;
             }
             break;
     
         case 0: // validation failed or some other error
             $out = '<div class="cge_sig sig_error" title="'.$cge->Lang('info_vrfy_failed').'"/>';
             $out .= '<span>'.$rec['message'].'</span>';
             $out .= '</div>';
             $out .= '<div class="clearb"></div>';
             echo $out;
             break;
     
         case 1:
             // it is all good, display the module signature.
             $out = '<div class="cge_sig" title="'.$cge->Lang('info_vrfy_signature').'"/>';
             $out .= $cge->Lang('module_signature').':';
             $out .= '<span>'.$rec['checksum'].'</span>';
             $out .= '</div>';
             $out .= '<div class="clearb"></div>';
             echo $out;
             break;
         }
     }
     */
     // redundant for cmsms 2.0
     $smarty = null;
     if (version_compare(CMS_VERSION, '2.0.1') < 0) {
         $smarty = Smarty_CMS::get_instance();
     } else {
         $smarty = $this->GetActionTemplateObject();
     }
     $smarty->assign('actionid', $id);
     $smarty->assign('actionparams', $params);
     $smarty->assign('returnid', $returnid);
     $smarty->assign('mod', $this);
     $smarty->assign($this->GetName(), $this);
     cge_tmpdata::set('module', $this->GetName());
     if ($returnid == '') {
         // admin action
         if (isset($params['cg_activetab'])) {
             $this->_current_tab = trim($params['cg_activetab']);
             unset($params['cg_activetab']);
         }
         if (isset($params['cg_error'])) {
             $this->_errormsg = explode(':err:', $params['cg_error']);
             unset($params['cg_error']);
         }
         if (isset($params['cg_message'])) {
             $this->_messages = explode(':msg:', $params['cg_message']);
             unset($params['cg_message']);
         }
         $this->DisplayErrors();
         $this->DisplayMessages();
     }
     parent::DoAction($name, $id, $params, $returnid);
 }
 public function DoAction($name, $id, $params, $returnid = '')
 {
     if (!method_exists($this, 'set_action_id') && $this->GetName() != 'CGExtensions') {
         die('FATAL ERROR: A module derived from CGExtensions is not handling the set_action_id method');
     }
     $this->set_action_id($id);
     // handle the stupid input type='image' problem.
     foreach ($params as $key => $value) {
         if (endswith($key, '_x')) {
             $base = substr($key, 0, strlen($key) - 2);
             if (isset($params[$base . '_y']) && !isset($params[$base])) {
                 $params[$base] = $base;
             }
         }
     }
     $smarty = cmsms()->GetSmarty();
     $smarty->assign('actionid', $id);
     $smarty->assign('actionparams', $params);
     $smarty->assign('returnid', $returnid);
     $smarty->assign_by_ref('mod', $this);
     $smarty->assign_by_ref($this->GetName(), $this);
     cge_tmpdata::set('module', $this->GetName());
     if ($returnid == '') {
         if (isset($params['cg_activetab'])) {
             $this->_current_tab = trim($params['cg_activetab']);
             unset($params['cg_activetab']);
         }
         if (isset($params['cg_error'])) {
             $this->_errormsg = explode(':err:', $params['cg_error']);
             unset($params['cg_error']);
         }
         if (isset($params['cg_message'])) {
             $this->_messages = explode(':msg:', $params['cg_message']);
             unset($params['cg_message']);
         }
         $this->DisplayErrors();
         $this->DisplayMessages();
     }
     $cge = $this->GetModuleInstance('CGExtensions');
     if ($cge->GetPreference('cache_modulecalls', 0) && (!isset($params['nocache']) || !$params['nocache']) && cms_cache_handler::can_cache()) {
         $key = '';
         if (isset($params['cache_key'])) {
             $key = trim($params['cache_key']);
         } else {
             $tmp = debug_backtrace();
             $bt = array();
             foreach ($tmp as $elem) {
                 $bt[] = $elem['file'] . ':' . $elem['line'];
             }
             $key = 'm' . md5($this->GetName() . serialize($params) . serialize($bt) . $id . $returnid);
         }
         $output = '';
         if (!cms_cache_handler::get_instance()->exists($key, 'cge_module')) {
             @ob_start();
             parent::DoAction($name, $id, $params, $returnid);
             $output = @ob_get_contents();
             @ob_end_clean();
             if (strlen($output)) {
                 cms_cache_handler::get_instance()->set($key, $output, 'cge_module');
             }
         } else {
             $output = cms_cache_handler::get_instance()->get($key, 'cge_module');
         }
         echo $output;
         return;
     }
     parent::DoAction($name, $id, $params, $returnid);
 }
 private function _old_LoggedInId()
 {
     $gCms = cmsms();
     $config = $gCms->GetConfig();
     if (cge_tmpdata::exists('feu_logginid')) {
         // this will save a few queries in each request
         return cge_tmpdata::get('feu_logginid');
     }
     $sessionid = session_id();
     $this->ExpireUsers();
     if ($sessionid == "") {
         return false;
     }
     $db = $this->GetDb();
     $module = $this->GetModule();
     $expirytime = $module->GetPreference('user_session_expires');
     $expireusers_interval = $module->GetPreference('expireusers_interval');
     $interval = min($expireusers_interval, $expirytime);
     $q = "SELECT userid FROM " . cms_db_prefix() . "module_feusers_loggedin WHERE sessionid=?";
     $p = array($sessionid);
     $result = $db->GetOne($q, $p);
     if ($result) {
         // we know this user is logged in.
         $retval = $result;
         // now touch the lastused
         // this will ensure that every time we check that a user is
         // logged in, it touches his logged in entry
         $q = "UPDATE " . cms_db_prefix() . "module_feusers_loggedin SET lastused = ? where sessionid = ?";
         $db->Execute($q, array(time(), $sessionid));
         // refresh the cookie.
         @setcookie('feu_sessionid', $sessionid, time() + $expirytime, "/");
         @setcookie('feu_uid', $uid, time() + $expirytime, "/");
         cge_tmpdata::set('feu_logginid', $retval);
         // set some session data to save some db queries.
         // and send an event.
         $module->SendEvent('OnRefreshUser', array('id' => $retval));
         return $retval;
     } else {
         if ($module->GetPreference('cookie_keepalive', 0) && isset($_COOKIE['feu_sessionid']) && isset($_COOKIE['feu_uid'])) {
             // no session id, but we have a cookie, so what we'll do
             // is first check to see if the session is still logged in
             // if it is, force a logout for that session id
             // and start a new record, otherwise, ignore the cookie
             $uid = $_COOKIE['feu_uid'];
             $sessionid = $_COOKIE['feu_sessionid'];
             // delete the existing record
             $q = "DELETE FROM " . cms_db_prefix() . "module_feusers_loggedin \n                        WHERE sessionid = ?";
             $db->Execute($q, array($sessionid));
             // log the user in
             // todo, log this too,
             // rationalize this code with Login() and Logout() methods
             @session_start();
             $sessionid = session_id();
             $q = "INSERT INTO " . cms_db_prefix() . "module_feusers_loggedin\n                    (sessionid,lastused,userid)\n                  VALUES (?,?,?)";
             $db->Execute($q, array($sessionid, time(), $uid));
             // set the cookie again
             @setcookie('feu_sessionid', $sessionid, time() + $expirytime, "/");
             @setcookie('feu_uid', $uid, time() + $expirytime, "/");
             cge_tmpdata::set('feu_logginid', $uid);
             $module->SendEvent('OnRefreshUser', array('id' => $uid));
             return $uid;
         } else {
             $res = $this->_attempt_login_with_cookie();
             if (!is_array($res) || $res[0] == FALSE) {
                 return false;
             }
             $module->SendEvent('OnRefreshUser', array('id' => $res[0]));
             return $res[0];
         }
     }
     return false;
 }