public function __construct($input)
 {
     $percent = 50;
     $h_align = CGImage_Crop_Filter::ALIGN_CENTER;
     $v_align = CGImage_Crop_Filter::ALIGN_CENTER;
     if (cge_array::is_hash($input)) {
         $percent = (int) $input['percent'];
         $h_align = trim($params['h']);
         $v_align = trim($params['v']);
     } else {
         if (is_array($input)) {
             if (count($input) > 1) {
                 $percent = (int) $input[0];
             }
             if (count($input) == 3) {
                 $h_align = trim($input[1]);
                 $v_align = trim($input[2]);
             }
         }
     }
     $this->_percent = min(100, max(1, $percent));
     switch ($h_align) {
         case '-1':
         case 'left':
         case 'l':
             $this->_h_align = self::ALIGN_LEFT;
             break;
         case '0':
         case 'c':
         case 'center':
             $this->_h_align = self::ALIGN_CENTER;
             break;
         case '1':
         case 'r':
         case 'right':
             $this->_h_align = self::ALIGN_RIGHT;
             break;
         default:
             throw new Exception('Invalid value ' . $h_align . ' for horizontal alignment');
     }
     switch ($v_align) {
         case '-1':
         case 't':
         case 'top':
             $this->_v_align = self::ALIGN_TOP;
             break;
         case '0':
         case 'c':
         case 'center':
             $this->_v_align = self::ALIGN_CENTER;
             break;
         case '1':
         case 'b':
         case 'bottom':
             $this->_v_align = self::ALIGN_BOTTOM;
             break;
         default:
             throw new Exception('Invalid value ' . $h_align . ' for horizontal alignment');
     }
 }
 public function __construct($input)
 {
     if (cge_array::is_hash($input)) {
         if (isset($input['width'])) {
             $this->_dest_w = (int) $input['width'];
             $this->_dest_h = (int) $input['height'];
         } else {
             if (isset($input['w'])) {
                 $this->_dest_w = (int) $input['w'];
                 $this->_dest_h = (int) $input['h'];
             }
         }
         if (isset($input['loc']) && in_array($input['loc'], self::$_valid_locs)) {
             $this->_loc = trim($input['loc']);
         }
     } else {
         if (is_array($input)) {
             if (count($input) >= 2) {
                 $this->_dest_w = (int) trim($input[0]);
                 $this->_dest_h = (int) trim($input[1]);
                 if (count($input) >= 3 && in_array($input[2], self::$_valid_locs)) {
                     $this->_loc = trim($input[2]);
                 }
             }
         }
     }
     if ($this->_dest_h <= 0 || $this->_dest_w <= 0) {
         throw new Exception('Invalid values specified for Croptofit filter constructor');
     }
 }
 private function reorder_customfields($customfields)
 {
     $fields = cms_utils::get_module('CGCalendar')->GetFields();
     $fields = cge_array::to_hash($fields, 'field_name');
     $func = function ($a, $b) use($fields) {
         if ($a['event_id'] < $b['event_id']) {
             return -1;
         }
         if ($a['event_id'] > $b['event_id']) {
             return 1;
         }
         $aa = $fields[$a['field_name']];
         $aa = $fields[$b['field_name']];
         if ($aa['field_order'] < $bb['field_order']) {
             return -1;
         }
         if ($aa['field_order'] > $bb['field_order']) {
             return 1;
         }
         // now compare by field value.
         if ($a['field_value'] < $b['field_value']) {
             return -1;
         }
         if ($a['field_value'] > $b['field_value']) {
             return -1;
         }
         return 0;
     };
     usort($customfields, $func);
 }
 private function _isAuthorized()
 {
     // do we have access to it?
     $this->_getData();
     $feu = cms_utils::get_module('FrontEndUsers');
     if (!$feu) {
         return FALSE;
     }
     $uid = $feu->LoggedInId();
     if (!$uid) {
         return FALSE;
     }
     // not logged in is a false.
     if (!isset($this->_data['groups']) || count($this->_data['groups']) == 0) {
         // no member groups selected, but still logged in, we can display this.
         return TRUE;
     }
     // get member groups and do a cross reference.
     $groups = $feu->GetMemberGroupsArray($uid);
     if (!is_array($groups) || count($groups) == 0) {
         return FALSE;
     }
     $membergroups = cge_array::extract_field($groups, 'groupid');
     for ($i = 0; $i < count($this->_data['groups']); $i++) {
         if (in_array($this->_data['groups'][$i], $membergroups)) {
             return TRUE;
         }
     }
     // no match.
     return FALSE;
 }
 public function __construct()
 {
     $input = func_get_args();
     if (count($input) == 1 && is_array($input[0])) {
         $input = $input[0];
     }
     if (cge_array::is_hash($input)) {
         $this->_wmtext = \cge_param::get_string($input, 'text');
     } else {
         if (is_array($input) && count($input) >= 1) {
             $tmp = \cge_param::get_string($input, 0);
             if (is_string($tmp) && !is_numeric($tmp)) {
                 $this->_wmtext = $tmp;
             }
         }
     }
 }
 public function __construct()
 {
     $input = func_get_args();
     if (is_array($input) && count($input) == 1) {
         $input = $input[0];
     }
     $this->_divisor = array_sum(array_map('array_sum', $this->_matrix));
     $adj = 0;
     if (cge_array::is_hash($input) && isset($input['divisor'])) {
         $adj = (double) $input['divisor'];
     } else {
         if (is_array($input) && count($input) >= 1) {
             $adj = (double) $input[0];
         }
     }
     $this->_divisor += max(-10, min(10, $adj));
 }
 public function __construct($input)
 {
     $mod = cms_utils::get_module('CGSmartImage');
     $this->_loc = $mod->GetPreference('croptofit_default_loc', 'c');
     if (cge_array::is_hash($input)) {
         if (isset($input['width'])) {
             $this->_dest_w = (int) $input['width'];
             $this->_dest_h = (int) $input['height'];
         } else {
             if (isset($input['w'])) {
                 $this->_dest_w = (int) $input['w'];
                 $this->_dest_h = (int) $input['h'];
             }
         }
         if (isset($input['color']) && $input['color'] != '') {
             $this->_color = strtolower($input['color']);
         }
         if (isset($input['alpha'])) {
             $this->_alpha = (int) $input['alpha'];
         }
     } else {
         if (is_array($input)) {
             if (count($input) >= 2) {
                 $this->_dest_w = (int) trim($input[0]);
                 $this->_dest_h = (int) trim($input[1]);
                 if (count($input) >= 3) {
                     if ($input[2] != '') {
                         $this->_color = strtolower($input[2]);
                     }
                     if (count($input) >= 4) {
                         if ($input[3] != '') {
                             $this->_alpha = (int) $input[3];
                         }
                     }
                 }
             }
         }
     }
     $this->_dest_w = cgsi_utils::trim_to_device('width', $this->_dest_w);
     $this->_dest_h = cgsi_utils::trim_to_device('height', $this->_dest_h);
     $this->_alpha = max(0, min(127, $this->_alpha));
     // todo: convert color name into rgb.
     if ($this->_dest_h <= 0 || $this->_dest_w <= 0) {
         throw new Exception('Invalid values specified for Croptofit filter constructor');
     }
 }
 public function __construct($input)
 {
     $mod = cms_utils::get_module('CGSmartImage');
     $this->_loc = $mod->GetPreference('croptofit_default_loc', 'c');
     if (cge_array::is_hash($input)) {
         if (isset($input['width'])) {
             $this->_dest_w = (int) $input['width'];
             $this->_dest_h = (int) $input['height'];
         } else {
             if (isset($input['w'])) {
                 $this->_dest_w = (int) $input['w'];
                 $this->_dest_h = (int) $input['h'];
             }
         }
         if (isset($input['loc']) && in_array($input['loc'], self::$_valid_locs)) {
             $this->_loc = $input['loc'];
         }
         if (isset($input['upscale'])) {
             $this->_upscale = (int) $input['upscale'];
         }
     } else {
         if (is_array($input)) {
             if (count($input) >= 2) {
                 $this->_dest_w = (int) trim($input[0]);
                 $this->_dest_h = (int) trim($input[1]);
                 if (count($input) >= 3 && in_array($input[2], self::$_valid_locs)) {
                     $this->_loc = $input[2];
                 }
                 if (count($input) >= 4) {
                     $this->_upscale = (int) $input[3];
                 }
             }
         }
     }
     if (!$this->_upscale) {
         $this->_dest_w = cgsi_utils::trim_to_device('width', $this->_dest_w);
         $this->_dest_h = cgsi_utils::trim_to_device('height', $this->_dest_h);
     }
     if ($this->_dest_h <= 0 || $this->_dest_w <= 0) {
         throw new Exception('Invalid values specified for Croptofit filter constructor');
     }
 }
 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;
     }
 }
Ejemplo n.º 10
0
 public static function current_url()
 {
     // rebuild the current url.
     $config = cmsms()->GetConfig();
     $uri_parts = explode('/', $_SERVER['REQUEST_URI']);
     $uri_parts = cge_array::remove_by_value($uri_parts);
     $tmp = parse_url($config['root_url']);
     $root_parts = array();
     if (isset($tmp['path'])) {
         $root_parts = explode('/', $tmp['path']);
         $root_parts = cge_array::remove_by_value($root_parts);
     }
     $newdata = array();
     for ($i = 0; $i < max(count($uri_parts), count($root_parts)); $i++) {
         if ($i < count($uri_parts) && $i < count($root_parts) && $root_parts[$i] == $uri_parts[$i]) {
             continue;
         }
         $newdata[] = $uri_parts[$i];
     }
     $url = $config['root_url'] . '/' . implode('/', $newdata);
     return $url;
 }
 public function __construct($input)
 {
     if (cge_array::is_hash($input)) {
         if (isset($input['radius'])) {
             $this->_radius = (int) $input['radius'];
         }
         if (isset($input['color'])) {
             $this->_color = $input['color'];
         }
     } else {
         if (is_array($input)) {
             if (count($input) >= 1) {
                 $this->_radius = (int) $input[0];
             }
             if (count($input) >= 2) {
                 $this->_color = $input[1];
             }
         }
     }
     if ($this->_radius <= 1) {
         throw new Exception('Invalid values specified for Roundedcorners filter constructor');
     }
 }
// put the query together
if (count($where)) {
    $query .= ' WHERE ' . implode(' AND ', $where);
}
$rs = $db->SelectLimit($query, $limit, 0, $parms);
$list1 = array();
debug_to_log($db->sql);
while (!$rs->EOF) {
    $list1[] = $rs->fields;
    $rs->MoveNext();
}
unset($rs);
debug_to_log($list1);
if (count($list1)) {
    // get the categorie(s) for these events
    $idlist = cge_array::extract_field($list1, 'event_id');
    $query = 'SELECT * FROM ' . $this->events_to_categories_table_name . ' WHERE event_id IN (' . implode(',', $idlist) . ') ORDER BY event_id,category_id';
    $tmp = $db->GetArray($query);
    $category_list = array();
    if (is_array($tmp) && count($tmp)) {
        foreach ($tmp as $rec) {
            $category_list[$rec['event_id']][] = $rec['category_id'];
        }
    }
    // now convert this into something compatible with fullcalendar
    $outlist = array();
    foreach ($list1 as $rec) {
        try {
            $out = new stdClass();
            $out->id = $rec['event_id'];
            $out->title = $rec['event_title'];
Ejemplo n.º 13
0
function cge_CreateInputHidden(&$mod, $id, $name, $value = '', $addtext = '', $delim = ',')
{
    if (is_array($value)) {
        $val = cge_array::implode_with_key($value);
    } else {
        $val = $value;
    }
    $val = str_replace('"', '&quot;', $val);
    $text = '<input type="hidden" name="' . $id . $name . '" value="' . $val . '"';
    if ($addtext != '') {
        $text .= ' ' . $addtext;
    }
    $text .= " />\n";
    return $text;
}
Ejemplo n.º 14
0
            $tfields[$i]['input'] = $this->CreateTextArea(isset($tfields[$i]['attrib']['usewysiwyg']) && $tfields[$i]['attrib']['usewysiwyg'] == 1 && $this->GetPreference('allow_comment_wysiwyg', 0), $id, $tfields[$i]['value'], 'field_' . $tfields[$i]['id']);
            break;
        case 'dropdown':
        case 'multiselect':
            if (isset($tfields[$i]['attrib']['options'])) {
                $tmp = explode("\n", $tfields[$i]['attrib']['options']);
                $tmp2 = array();
                foreach ($tmp as $one) {
                    $key = $value = $one;
                    if (strpos($one, '=') !== FALSE) {
                        list($key, $value) = explode('=', trim($one), 2);
                    }
                    $tmp2[trim($value)] = trim($key);
                }
                $tfields[$i]['attrib']['options'] = $tmp2;
                $tfields[$i]['value'] = cge_array::smart_explode($tfields[$i]['value']);
            }
            break;
    }
    $fields[$tfields[$i]['id']] = $tfields[$i];
}
// populate the template
$smarty->assign("startform", $this->CreateFormStart($id, 'do_editupload', $returnid, 'post', 'multipart/form-data'));
// todo check this to see if there are spaces in the name
$addtext_thumbnail = 'title="' . $this->Lang('title_create_thumbnail') . '"';
// $smarty->assign ('fix',
// 		 $this->CreateInputSubmit ($id, 'fix', $this->Lang('fixme')));
$smarty->assign('thumbnail', $this->CreateInputSubmit($id, 'thumbnail', $this->Lang('create_thumbnail'), $addtext_thumbnail));
$smarty->assign('submit', $this->CreateInputSubmit($id, 'submit', $this->Lang('submit')));
$smarty->assign('cancel', $this->CreateInputSubmit($id, 'cancel', $this->Lang('cancel')));
$smarty->assign('endform', $this->CreateFormEnd());
# 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
// fill out the template
$smarty->assign('startform', $this->CreateFormStart($id, 'do_setprefs'));
$months = array();
for ($i = 520; $i > 0; $i--) {
    $months[$i] = $i;
}
$smarty->assign('auto_create_unknown', $this->GetPreference('auto_create_unknown', 0));
$auth_modules = module_helper::get_modules_with_method('GetFEUAuthConsumer');
$auth_modules = cge_array::hash_prepend($auth_modules, '__BUILTIN__', $this->Lang('auth_builtin'));
$smarty->assign('auth_modules', $auth_modules);
$smarty->assign('auth_module', $this->GetPreference('auth_module', '__BUILTIN__'));
$smarty->assign('input_randomusername', RRUtils::myCreateInputCheckbox($id, 'input_randomusername', 1, $this->GetPreference('use_randomusername', 0)));
$smarty->assign('input_expireage', $this->CreateInputDropdown($id, 'input_expireage', $months, -1, $this->GetPreference('expireage_months', 260)));
$smarty->assign('prompt_sessiontimeout', $this->Lang('prompt_sessiontimeout'));
$smarty->assign('input_sessiontimeout', $this->CreateInputText($id, 'input_sessiontimeout', $this->GetPreference('user_session_expires'), 6, 6));
$smarty->assign('prompt_requireonegroup', $this->Lang('prompt_requireonegroup'));
$smarty->assign('input_requireonegroup', RRUtils::myCreateInputCheckbox($id, 'input_requireonegroup', 1, $this->GetPreference('require_onegroup')));
$smarty->assign('prompt_feusers_specific_permissions', $this->Lang('prompt_feusers_specific_permissions'));
$smarty->assign('input_feusers_specific_permissions', RRUtils::myCreateInputCheckbox($id, 'input_feusers_specific_permissions', 1, $this->GetPreference('feusers_specific_permissions')));
$smarty->assign('info_feusers_specific_permissions', $this->Lang('info_feusers_specific_permissions'));
$smarty->assign('prompt_dfltgroup', $this->Lang('prompt_dfltgroup'));
$groups1 = $this->GetGroupList();
$groups = array_merge(array("None" => -1), $groups1);
$smarty->assign('input_dfltgroup', $this->CreateInputDropDown($id, 'input_dfltgroup', $groups, -1, $this->GetPreference('default_group')));
if (!$order_obj) {
    return;
}
if ($order_obj->get_status() != ORDERSTATUS_SUBSCRIBED && $order_obj->get_status() != ORDERSTATUS_PAID) {
    // don't do anything unless we're dealing with a subscribed order.
    return;
}
// get the list of packages
$pkgs = '';
$query = 'SELECT * FROM ' . cms_db_prefix() . 'module_selfreg_paidpkgs';
$tmp = $db->GetArray($query);
if (!$tmp) {
    return;
    // no packages
}
$pkgs = cge_array::to_hash($tmp, 'id');
// 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() != $this->GetName()) {
            continue;
        }
        if ($item->get_item_type() != line_item::ITEMTYPE_SERVICE) {
            continue;
        }
        //if( !$item->is_subscription() ) continue;
        $temp_uid = $item->get_item_id();
        $sku = $item->get_sku();
        if (!$sku) {
 public static function cge_setlist($params, $smarty)
 {
     $name = get_parameter_value($params, 'array');
     $name = get_parameter_value($params, 'name', $name);
     $key = get_parameter_value($params, 'key');
     $val = get_parameter_value($params, 'value');
     $name = trim($name);
     $key = trim($key);
     if (!$name || !isset($params['value'])) {
         return;
     }
     $parts = explode('.', $name);
     $data = array();
     if (!is_array($parts) || count($parts) == 0) {
         return;
     }
     if ($key) {
         $parts[] = $key;
     }
     $smarty = CmsApp::get_instance()->GetSmarty();
     $name = $parts[0];
     $data = $smarty->get_template_vars($name);
     if (!$data) {
         $data = array();
     }
     if (!is_array($data)) {
         $data = array($data);
     }
     // {cge_setlist name='a.b.c.d' value='55'}
     $ref =& $data;
     $i = 0;
     for ($i = 1; $i < count($parts) - 1; $i++) {
         if (!isset($ref[$parts[$i]]) || !is_array($ref[$parts[$i]])) {
             if ($i < count($parts) - 1) {
                 $ref[$parts[$i]] = array();
             }
         }
         $ref =& $ref[$parts[$i]];
     }
     // expect a list of values... may contain key/value pairs
     if (strpos($val, '::') === FALSE) {
         $ref[$parts[$i]] = $val;
     } else {
         $tmp = cge_array::smart_explode($val, '||');
         if (is_array($tmp) && count($tmp)) {
             $ref[$parts[$i]] = array();
             for ($j = 0; $j < count($tmp); $j++) {
                 $k = '';
                 $v = $tmp[$j];
                 if (strpos($v, '::') !== FALSE) {
                     list($k, $v) = explode('::', $tmp[$j], 2);
                 }
                 if ($k) {
                     $k = trim(trim($k, '"'));
                 }
                 if ($v) {
                     $v = trim(trim($v, '"'));
                 }
                 if ($k) {
                     $ref[$parts[$i]][$k] = $v;
                 } else {
                     $ref[$parts[$i]][] = $v;
                 }
             }
         }
     }
     // put the data back
     $smarty->assign($name, $data);
     // done.
 }
Ejemplo n.º 18
0
 public static function get_categories($by_id = FALSE)
 {
     if (!is_array(self::$_cached_categories)) {
         $db = cmsms()->GetDb();
         self::$_cached_categories = array();
         $mod = \cms_utils::get_module(MOD_CGCALENDAR);
         $categories_table_name = $mod->categories_table_name;
         $sql = "SELECT * FROM {$mod->categories_table_name} ORDER BY category_order, category_name";
         self::$_cached_categories = $db->GetArray($sql);
     }
     if ($by_id) {
         return \cge_array::to_hash(self::$_cached_categories, 'category_id');
     }
     return self::$_cached_categories;
 }
        $this->Redirect($id, 'changesettings', $returnid, $params);
    }
}
// get property definitions
$defnsbyname = $this->GetPropertyDefns();
// Get member groups
$groups = $this->GetMemberGroupsArray($uid);
// Get group property relations into a union.
$properties = array();
$tmp = array();
foreach ($groups as $onegroup) {
    $proprelations = $this->GetGroupPropertyRelations($onegroup['groupid']);
    $tmp = RRUtils::array_merge_by_name_required($tmp, $proprelations);
    uasort($tmp, array('cge_array', 'compare_elements_by_sortorder_key'));
}
$properties = cge_array::to_hash($tmp, 'name');
$userprops = $this->GetUserProperties($uid);
// do validation of the fields.
foreach ($properties as $propname => $prop) {
    $fldtype = $defnsbyname[$propname]['type'];
    $required = $prop['required'] == 2;
    switch ($fldtype) {
        case '0':
            /* text */
            if ($required) {
                if (!isset($params['feu_input_' . $propname]) || empty($params['feu_input_' . $propname])) {
                    $params['error'] = 1;
                    $params['message'] = $this->Lang('error_requiredfield', $defnsbyname[$propname]['prompt']);
                    $this->Redirect($id, 'changesettings', $returnid, $params);
                }
            }
Ejemplo n.º 20
0
}
$parms = $params;
$parms['feedback_origpage'] = $returnid;
$data = array();
while ($dbr && ($row = $dbr->FetchRow())) {
    $prettyurl = "feedback/detail/{$row['id']}/{$detailpage}/";
    $prettyurl .= munge_string_to_url(substr($row['title'], 0, 30));
    $parms['cid'] = $row['id'];
    $row['detail_url'] = $this->CreateURL($id, 'detail', $detailpage, $parms, 0, $prettyurl);
    $sql = 'SELECT * FROM ' . CGFEEDBACK_TABLE_FIELDVALS . ' WHERE comment_id = ?';
    $tmp = $db->GetArray($sql, array($row['id']));
    if (is_array($tmp) && is_array($fields)) {
        for ($i = 0; $i < count($tmp); $i++) {
            $tmp[$i] = array_merge($tmp[$i], $fields[$tmp[$i]['field_id']]);
        }
        $row['fields'] = cge_array::to_hash($tmp, 'name');
    }
    $tmp = $fields;
    $data[] = $row;
}
#
# Give everything to smarty
#
$config = $gCms->GetConfig();
$path = $config['root_url'] . '/modules/' . $this->GetName() . '/images/';
$tmp = array('img_on' => $path . 'star.gif', 'img_off' => $path . 'starOff.gif', 'img_half' => $path . 'starHalf.gif');
$smarty->assign('rating_imgs', $tmp);
$smarty->assign('total_records', $total_records);
$smarty->assign('pagecount', $pagecount);
$smarty->assign('pagenum', $pagenum);
$parms = $params;
 public function check_extrafiles()
 {
     // walk the directory, generate the key, see if there are any extra files
     $dir = $this->_mod->GetModulePath();
     $cdata = $this->parse_cdat();
     $cdata = \cge_array::to_hash($cdata, 'file');
     $tmpdata = array();
     $this->walk_directory($dir, function ($path) use(&$tmpdata, $cdata) {
         $key = $this->get_checksum_key($path);
         if (!isset($cdata[$key])) {
             $tmpdata[] = $path;
         }
     });
     if (count($tmpdata)) {
         return $tmpdata;
     }
 }
$this->SetCurrentTab('fields');
$nupdates = 0;
$nadds = 0;
$ids = $params['field_ids'];
// (old names... empty value indicates an add)
$names = $params['field_names'];
$types = $params['field_types'];
if (isset($params['field_searchable'])) {
    $searchable = $params['field_searchable'];
}
if (isset($params['field_wysiwyg'])) {
    $wysiwyg = $params['field_wysiwyg'];
}
// find deletions.
$fields = $this->GetFields();
$field_names = cge_array::extract_field($fields, 'field_name');
$deleted = array();
foreach ($field_names as $name) {
    if ($name == '') {
        continue;
    }
    if (!in_array($name, $names)) {
        _cgcalDeleteField($name);
    }
}
// now process new records and updates
$num_records = count($ids);
$field_order = -1;
for ($i = 0; $i < $num_records; $i++) {
    $field_oldname = $ids[$i];
    $field_newname = trim($names[$i]);
Ejemplo n.º 23
0
}
unset($params['category']);
$params['category_id'] = $tmp;
if (isset($params['key'])) {
    $params['input_key'] = $params['key'];
    unset($params['key']);
}
$smarty->assign('startform', $this->CreateFormStart($id, 'do_upload', $returnid, 'post', 'multipart/form-data', $params));
$smarty->assign('prompt_upload', $this->Lang('upload'));
// get custom field info.
$fields = array();
$query = 'SELECT * FROM ' . cms_db_prefix() . 'module_uploads_fielddefs WHERE public = 1 ORDER BY iorder';
$tfields = $db->GetArray($query);
$query = 'SELECT * FROM ' . cms_db_prefix() . 'module_uploads_fieldvals WHERE upload_id = ?';
$tmp = $db->GetArray($query, array($params['upload_id']));
$tvals = cge_array::to_hash($tmp, 'fld_id');
for ($i = 0; $i < count($tfields); $i++) {
    $tfields[$i]['attrib'] = unserialize($tfields[$i]['attribs']);
    unset($tfields[$i]['attribs']);
    $tfields[$i]['value'] = $tvals[$tfields[$i]['id']]['value'];
    switch ($tfields[$i]['type']) {
        case 'textarea':
            $tfields[$i]['input'] = $this->CreateTextArea(isset($tfields[$i]['attrib']['usewysiwyg']) && $tfields[$i]['attrib']['usewysiwyg'] == 1 && $this->GetPreference('allow_comment_wysiwyg', 0), $id, $tfields[$i]['value'], 'field_' . $tfields[$i]['id']);
            break;
        case 'dropdown':
        case 'multiselect':
            if (isset($tfields[$i]['attrib']['options'])) {
                $tmp = explode("\n", $tfields[$i]['attrib']['options']);
                $tmp2 = array();
                foreach ($tmp as $one) {
                    $one = trim($one);
Ejemplo n.º 24
0
        } else {
            $onerow->iconurl = $imgpath . 'unknown.png';
        }
        $onerow->description = $row['upload_description'];
        $onerow->ip = $row['upload_ip'];
        $onerow->size = intval($row['upload_size'] / 1024.0 + 0.5);
        $onerow->date = $row['upload_date'];
        $query = 'SELECT A.id,A.name,A.type,B.upload_id,B.value 
              FROM ' . cms_db_prefix() . 'module_uploads_fielddefs A 
              LEFT JOIN ' . cms_db_prefix() . 'module_uploads_fieldvals B 
                ON A.id = B.fld_id 
             WHERE B.upload_id = ? AND A.public = 1
             ORDER BY A.iorder ASC';
        $tmp = $db->GetArray($query, array($row['upload_id']));
        if ($tmp) {
            $hash = cge_array::to_hash($tmp, 'name');
            $onerow->fieldvals = array();
            foreach ($hash as $k => $v) {
                $onerow->fieldvals[$k] = $v['value'];
            }
            $onerow->fields = $hash;
        }
        $rowarray[] = $onerow;
    }
    $smarty->assign('items', $rowarray);
    $smarty->assign('itemcount', count($rowarray));
}
// Display the populated template
if ($params['mode'] != 'select') {
    echo $this->ProcessTemplateFromDatabase($template);
}
 public static function cge_array_pop($params, &$smarty)
 {
     if (!isset($params['array'])) {
         return;
     }
     $arr = get_parameter_value($params, 'array');
     if (!$arr) {
         return;
     }
     if (!cge_tmpdata::exists($arr)) {
         return;
     }
     $data = cge_array::get($arr);
     if (!is_array($data)) {
         return;
     }
     $ret = array_pop($data);
     cge_tmpdata::set($arr, $data);
     if (isset($params['assign'])) {
         $smarty->assign(trim($params['assign']), $ret);
         return;
     }
     return $ret;
 }
 private function _get_groups()
 {
     if (!is_array($this->_groups)) {
         $feu = cge_utils::get_module('FrontEndUsers');
         $tmp = $feu->GetGroupListFull();
         if (is_array($tmp) && count($tmp)) {
             $this->_groups = cge_array::to_hash($tmp, 'groupname');
         }
     }
     return $this->_groups;
 }
Ejemplo n.º 27
0
            }
            $query .= ')';
        }
        if (isset($params['unique_only']) && $params['unique_only']) {
            $query .= ' GROUP BY ev.event_title';
        }
        if (count($having)) {
            $query .= ' HAVING ';
            $query .= '(' . implode(' AND ', $having) . ')';
        }
        $query .= ' ORDER BY ev.event_date_start ASC';
        $searchresults = $db->GetArray($query, $qparms);
        if (!$searchresults && $db->ErrorMsg != '') {
            $error = $this->Lang('error_query_failed');
        }
        $searchresults = cge_array::extract_field($searchresults, 'event_id');
    }
}
$tpl = $this->CreateSmartyTemplate($thetemplate, 'searchresult_');
// calculate pagination stuff
// and the subset of event ids.
$numpages = 0;
$num_matches = 0;
if (!empty($searchresults)) {
    $num_matches = count($searchresults);
    $numpages = (int) (count($searchresults) / $limit);
    if (count($searchresults) % $limit > 0) {
        $numpages++;
    }
    $startoffset = ($pagenum - 1) * $limit;
    $entries = cgcalendar_utils::expand_events($searchresults, $returnid, $params, $limit, $startoffset);
         }
         $query = "SELECT A.id,";
         $flds = array();
         $conds = array();
         for ($i = 0; $i < count($viewprops); $i++) {
             $prop = $viewprops[$i];
             $nm = 'j' . $i;
             $flds[] = "{$nm}.data as {$prop}";
             $conds[] = cms_db_prefix() . "module_feusers_properties AS {$nm} ON A.id = {$nm}.userid AND ({$nm}.title = '{$prop}')";
         }
         $query .= implode(',', $flds) . ' FROM ' . cms_db_prefix() . 'module_feusers_users A';
         $query .= ' LEFT JOIN ' . implode(' LEFT JOIN ', $conds);
         $query .= ' WHERE A.id IN (' . implode(',', $uids) . ')';
         $dbr = $db->Execute('SET sql_big_selects = 1');
         $tmp = $db->GetArray($query);
         $extraprops = cge_array::to_hash($tmp, 'id');
     }
 }
 $rowarray = array();
 $rowclass = "row1";
 global $gCms;
 $smarty->assign('numusers', $numusers);
 if ($this->GetPreference('username_is_email')) {
     $smarty->assign('usernametext', $this->Lang('prompt_email'));
 } else {
     $smarty->assign('usernametext', $this->Lang('username'));
 }
 $smarty->assign('emailtext', $this->Lang('email'));
 $smarty->assign('statustext', $this->Lang('status'));
 $smarty->assign('createdtext', $this->Lang('created'));
 $smarty->assign('expirestext', $this->Lang('expires'));
Ejemplo n.º 29
0
    @trigger_error($this->GetName() . ' detail view: invalid comment id');
    return;
}
#
# Get the data
#
$data = $db->GetRow($query, array($cid, CGFEEDBACK_STATUS_PUBLISHED));
if (!$data) {
    return;
}
$query = 'SELECT A.name,A.type,B.value FROM ' . CGFEEDBACK_TABLE_FIELDDEFS . ' A 
          LEFT JOIN ' . CGFEEDBACK_TABLE_FIELDVALS . ' B 
          ON A.id = B.field_id WHERE B.comment_id = ?';
$fields = $db->GetArray($query, array($cid));
if (is_array($fields)) {
    $data['fields'] = cge_array::to_hash($fields, 'name');
}
#
# Give everything to smarty
#
$config = $gCms->GetConfig();
$path = $config['root_url'] . '/modules/' . $this->GetName() . '/images/';
$tmp = array('img_on' => $path . 'star.gif', 'img_off' => $path . 'starOff.gif', 'img_half' => $path . 'starHalf.gif');
$smarty->assign('rating_imgs', $tmp);
$smarty->assign('onecomment', $data);
#
# Display the template
#
echo $this->ProcessTemplateFromDatabase($thetemplate);
#
# EOF
                    // convert it to a comma separated list for storage
                    $fieldlist[$name] = implode(',', $fieldlist[$name]);
                }
                break;
            case 6:
                // image
                break;
            case 8:
                // date
                // todo, validate... against attribs.
                break;
        }
    }
}
// get the parms from the first step
$parms1 = cge_array::explode_with_key($params['step1_params']);
// and merge em into $params so we can actually add the user account
$params = array_merge($params, $parms1);
// now find out which groups he's a member of
$username = '';
if (isset($params['input_username'])) {
    $username = $params['input_username'];
}
$password = '';
if (isset($params['input_password']) && $params['input_password'] != '') {
    $password = $params['input_password'];
}
$expiresdate = strtotime('+10 years', time());
if (isset($params['input_expiresdate'])) {
    $expiresdate = $params['input_expiresdate'];
}