/** * @param int args[uid] userid */ public function userOnline($args) { $uid = $args['uid']; $tables = DBUtil::getTables(); $columns = $tables['session_info_column']; $where = "{$columns['uid']} = '" . DataUtil::formatForStore($uid) . "'"; return DBUtil::selectObject('session_info', $where); }
/** * Smarty function to wrap MUBoard_Form_View generated form controls with suitable form tags. * * @param array $params Parameters passed in the block tag. * @param string $content Content of the block. * @param Zikula_Form_View $view Reference to Zikula_Form_View object. * * @return string The rendered output. */ function smarty_block_muboardform($params, $content, $view) { if ($content) { PageUtil::addVar('stylesheet', 'system/Theme/style/form/style.css'); $encodingHtml = array_key_exists('enctype', $params) ? " enctype=\"{$params['enctype']}\"" : ''; $action = htmlspecialchars(System::getCurrentUri()); $classString = ''; if (isset($params['cssClass'])) { $classString = "class=\"{$params['cssClass']}\" "; } $request = new Zikula_Request_Http(); $id = $request->getGet()->filter('id', 0, FILTER_SANITIZE_NUMBER_INT); $forumid = $request->getGet()->filter('forum', 0, FILTER_SANITIZE_NUMBER_INT); // we check if the entrypoint is part of the url $stripentrypoint = ModUtil::getVar('ZConfig', 'shorturlsstripentrypoint'); // get url name $tables = DBUtil::getTables(); $modcolumn = $tables['modules_column']; $module = 'MUBoard'; $where = "{$modcolumn['name']} = '" . DataUtil::formatForStore($module) . "'"; $module = DBUtil::selectObject('modules', $where); $urlname = $module['url']; if (ModUtil::getVar('ZConfig', 'shorturls') == 0) { if (strpos($action, "func=display") !== false) { $action = 'index.php?module=' . $urlname . '&type=user&func=edit&ot=posting&answer=1'; } if (strpos($action, "func=edit&ot=posting") !== false && $forumid > 0) { $action = 'index.php?module=' . $urlname . '&type=user&func=edit&ot=posting&forum' . $forumid; } } else { if (strpos($action, $urlname . "/posting/id.") !== false) { if ($stripentrypoint == 1) { $action = $urlname . '/edit/ot/posting/answer/1'; } elseif ($stripentrypoint == 0) { $action = 'index.php/' . $urlname . '/edit/ot/posting/answer/1'; } } if (strpos($action, "edit/ot/posting/forum/") !== false && $forumid > 0) { if ($stripentrypoint == 1) { $action = $urlname . '/edit/ot/posting/forum/' . $forumid; } elseif ($stripentrypoint == 0) { $action = 'index.php/' . $urlname . '/edit/ot/posting/forum/' . $forumid; } } } $view->postRender(); $formId = $view->getFormId(); $out = "\n <form id=\"{$formId}\" {$classString}action=\"{$action}\" method=\"post\"{$encodingHtml}>\n {$content}\n <div>\n {$view->getStateHTML()}\n {$view->getStateDataHTML()}\n {$view->getIncludesHTML()}\n {$view->getCsrfTokenHtml()}\n <input type=\"hidden\" name=\"__formid\" id=\"form__id\" value=\"{$formId}\" />\n <input type=\"hidden\" name=\"FormEventTarget\" id=\"FormEventTarget\" value=\"\" />\n <input type=\"hidden\" name=\"FormEventArgument\" id=\"FormEventArgument\" value=\"\" />\n <script type=\"text/javascript\">\n <!--\n function FormDoPostBack(eventTarget, eventArgument)\n {\n var f = document.getElementById('{$formId}');\n if (!f.onsubmit || f.onsubmit())\n {\n f.FormEventTarget.value = eventTarget;\n f.FormEventArgument.value = eventArgument;\n f.submit();\n }\n }\n // -->\n </script>\n </div>\n </form>\n "; return $out; } }
public function validatePostProcess($type = 'user', $data = null) { $data = $this->_objData; if ($data['modname'] && $data['table'] && $data['property'] && (!isset($data['id']) || !$data['id'])) { $where = "WHERE modname='{$data['modname']}' AND entityname='{$data['table']}' AND property='{$data['property']}'"; $row = DBUtil::selectObject($this->_objType, $where); if ($row) { $_SESSION['validationErrors'][$this->_objPath]['property'] = __('Error! There is already a property with this name in the specified module and table.'); $_SESSION['validationFailedObjects'][$this->_objPath] = $this->_objData; return false; } } return true; }
public function get_hour($args) { $hid = FormUtil::getPassedValue('hid', isset($args['hid']) ? $args['hid'] : null, 'GET'); if (!isset($hid) || !is_numeric($hid)) { return LogUtil::registerError($this->__('Error! Could not do what you wanted. Please check your input.')); } $tablename = 'IWtimeframes'; $where = "hid =" . $hid; $item = DBUtil::selectObject($tablename, $where); if (!empty($item)) { return $item; } else { return false; } }
/** * Get application info. * * @param int $args['gid'] * @param int $args['userid'] * * @return array */ public function getapplicationinfo($args) { if (!isset($args['gid']) || !isset($args['userid'])) { return LogUtil::registerArgsError(); } $dbtable = DBUtil::getTables(); $col = $dbtable['group_applications_column']; $where = "WHERE {$col['gid']} = '" . DataUtil::formatForStore($args['gid']) . "'\n AND {$col['uid']} = '" . DataUtil::formatForStore($args['userid']) . "'"; $result = DBUtil::selectObject('group_applications', $where); if ($result === false) { return LogUtil::registerError($this->__('Error! Could not load data.')); } $appinfo = array('app_id' => $result['app_id'], 'appuid' => $result['uid'], 'appgid' => $result['gid'], 'application' => nl2br($result['application']), 'status' => $result['status']); return $appinfo; }
/** * get a specific item * @author Mark West * @param $args['sid'] id of news item to get * @return mixed item array, or false on failure */ public function get($args) { // optional arguments if (isset($args['objectid'])) { $args['sid'] = $args['objectid']; } // Argument check if ((!isset($args['sid']) || !is_numeric($args['sid'])) && !isset($args['title'])) { return LogUtil::registerArgsError(); } // Check for caching of the DBUtil calls (needed for AJAX editing) if (!isset($args['SQLcache'])) { $args['SQLcache'] = true; } // form a date using some ofif present... // step 1 - convert month name into if (isset($args['monthname']) && !empty($args['monthname'])) { $months = explode(' ', $this->__('Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec')); $keys = array_flip($months); $args['monthnum'] = $keys[ucfirst($args['monthname'])] + 1; } // step 2 - convert to a timestamp and back to a db format if (isset($args['year']) && !empty($args['year']) && isset($args['monthnum']) && !empty($args['monthnum']) && isset($args['day']) && !empty($args['day'])) { // use PHP strftime directly, since DateUtil translates dateformat strings, which is not ok in this case $timestring = strftime('%Y-%m-%d', mktime(0, 0, 0, $args['monthnum'], $args['day'], $args['year'])); } $permFilter = array(); $permFilter[] = array('realm' => 0, 'component_left' => 'News', 'component_middle' => '', 'component_right' => '', 'instance_left' => 'cr_uid', 'instance_middle' => '', 'instance_right' => 'sid', 'level' => ACCESS_READ); if (isset($args['sid']) && is_numeric($args['sid'])) { $item = DBUtil::selectObjectByID('news', $args['sid'], 'sid', null, $permFilter, null, $args['SQLcache']); } elseif (isset($timestring)) { $tables = DBUtil::getTables(); $col = $tables['news_column']; $where = "{$col['urltitle']} = '".DataUtil::formatForStore($args['title'])."' AND {$col['from']} LIKE '{$timestring}%'"; $item = DBUtil::selectObject('news', $where, null, $permFilter, null, $args['SQLcache']); } else { $item = DBUtil::selectObjectByID('news', $args['title'], 'urltitle', null, $permFilter, null, $args['SQLcache']); } if (empty($item)) return false; // Sanity check for the published status if required if (isset($args['status'])) { if ($item['published_status'] != $args['status']) { return false; } } // process the relative paths of the categories if ($this->getVar('enablecategorization') && !empty($item['__CATEGORIES__'])) { static $registeredCats; if (!isset($registeredCats)) { $registeredCats = CategoryRegistryUtil::getRegisteredModuleCategories('News', 'news'); } ObjectUtil::postProcessExpandedObjectCategories($item['__CATEGORIES__'], $registeredCats); if (!CategoryUtil::hasCategoryAccess($item['__CATEGORIES__'], 'News')) { return false; } } return $item; }
public function nommateria($args) { extract($args); $table = DBUtil::getTables(); $c = &$table['IWbooks_materies_column']; $where = "$c[codi_mat] = '$codi_mat'"; $item = DBUtil::selectObject('IWbooks_materies', $where); return $item['codi_mat']; }
/** * Gestiona-Informa dels usuaris d'un grup de zikula del catàleg * * > Retorna la informació de tots els membres del grup triat.\n * > Depenent del grup, permetrà la seva edició o només mostrarà la informació.\n * > Per als grups generals (Catàleg, Excatàleg, Personals, Genèrics) i pel grup Editors obtindrem la informació.\n * > El grup Gestors només podrà ser editat per el Gestor-Administrador. * * ### Paràmetres rebuts per GET: * * numeric **gid** gid del grup de zikula a gestionar. * * @return void Plantilla *Cataleg_admin_membersGroupview.tpl* o *Cataleg_admin_membersGroupgest.tpl* */ public function membersGroupgest() { //Comprovacions de seguretat. Només els gestors poden crear i editar usuaris if (!SecurityUtil::checkPermission('Cataleg::', '::', ACCESS_ADMIN)) { return LogUtil::registerPermissionError(); } $gid = FormUtil::getPassedValue('gid', null, 'GET'); $grup = UserUtil::getGroup($gid); //Només es poden gestionar els membres dels grups del catàleg $grupsUnitats = ModUtil::getVar('Cataleg', 'grupsUnitats'); $grupsZikula = ModUtil::getVar('Cataleg', 'grupsZikula'); if (!in_array($gid, $grupsUnitats) && !in_array($gid, $grupsZikula)) { LogUtil::registerError($this->__('No es poden gestionar els membres del grup indicat.')); return system::redirect(ModUtil::url('Cataleg', 'admin', 'groupsgest')); } $users = UserUtil::getUsers('', 'uname', -1, -1, 'uid'); foreach ($users as $key => $user) { $users[$key]['iw'] = DBUtil::selectObject('IWusers', 'where iw_uid =' . $key); } $catUsersList = UserUtil::getUsersForGroup($grupsZikula['Sirius']); $groupUsersList = UserUtil::getUsersForGroup($gid); foreach ($users as $user) { if (in_array($user['uid'], $catUsersList)) { if (in_array($user['uid'], $groupUsersList)) { $usuaris[1][] = $user; } else { $usuaris[0][] = $user; } } else { if (in_array($user['uid'], $groupUsersList)) { $usuaris[2][] = $user; } } } $this->view->assign('usuaris', $usuaris); $this->view->assign('grup', $grup); if ((!SecurityUtil::checkPermission('CatalegAdmin::', '::', ACCESS_ADMIN) && $gid == $grupsZikula['Gestors']) || $gid == $grupsZikula['UNI'] || $gid == $grupsZikula['ST'] || $gid == $grupsZikula['SE'] || $gid == $grupsZikula['Gestform'] || $gid == $grupsZikula['LectorsCat'] || $gid == $grupsZikula['EditorsCat'] || $gid == $grupsZikula['Personals'] || $gid == $grupsZikula['Generics'] || $gid == $grupsZikula['Sirius'] || $gid == $grupsZikula['ExSirius']) { return $this->view->fetch('admin/Cataleg_admin_membersGroupview.tpl'); } else { return $this->view->fetch('admin/Cataleg_admin_membersGroupgest.tpl'); } }
/** * Retrieve object meta data. * * @param array &$obj The object we wish to retrieve metadata for. * @param string $tablename The object's tablename. * @param string $idcolumn The object's idcolumn (optional) (default='id'). * * @return The object with the meta data filled in */ public static function retrieveObjectMetaData(&$obj, $tablename, $idcolumn = 'id') { $meta = self::fixObjectMetaData($obj, $tablename, $idcolumn); if ($meta['obj_id'] > 0) { $dbtables = DBUtil::getTables(); $meta_column = $dbtables['objectdata_meta_column']; $where = "WHERE {$meta_column['module']}='" . DataUtil::formatForStore($meta['module']) . "'\n AND {$meta_column['table']}='" . DataUtil::formatForStore($meta['table']) . "'\n AND {$meta_column['idcolumn']}='" . DataUtil::formatForStore($meta['idcolumn']) . "'\n AND {$meta_column['obj_id']}='" . DataUtil::formatForStore($meta['obj_id']) . "'"; return DBUtil::selectObject('objectdata_meta', $where); } return true; }
/** * Checks if user controlled block state. * * Checks if the user has a state set for a current block. * Sets the default state for that block if not present. * * @param array $blockinfo Block info. * * @return boolean */ public static function checkUserBlock($blockinfo) { if (!isset($blockinfo['bid'])) { $blockinfo['bid'] = ''; } if (UserUtil::isLoggedIn()) { $uid = UserUtil::getVar('uid'); $dbtable = DBUtil::getTables(); $column = $dbtable['userblocks_column']; $where = "WHERE $column[bid] = '" . DataUtil::formatForStore($blockinfo['bid']) . "' AND $column[uid] = '" . DataUtil::formatForStore($uid) . "'"; $result = DBUtil::selectObject('userblocks', $where); if ($result === false) { LogUtil::registerError(__f('Error! A database error occurred: \'%1$s: %2$s\'.', array($dbconn->ErrorNo(), $dbconn->ErrorMsg()))); return true; // FIXME: should this really return true (RNG) } if (!$result) { $uid = DataUtil::formatForStore($uid); $obj = array('uid' => $uid, 'bid' => $blockinfo['bid'], 'active' => $blockinfo['defaultstate']); if (!DBUtil::insertObject($obj, 'userblocks', 'bid', true)) { LogUtil::registerError(__f('Error! A database error occurred: \'%1$s: %2$s\'.', array($dbconn->ErrorNo(), $dbconn->ErrorMsg()))); return true; // FIXME: should this really return true (RNG) } return true; // FIXME: should this really return true (RNG) } else { return $result['active']; } } return false; }
/** * Funció per l'obtenció de la informació d'una entitat-gtaf * * > Obté un array amb la informació de l'entitat-gtaf * * @return array *gtafEntity* amb tota la informació de la entitat */ public function getGtafGroups($gtafgid) { $gtafInfo = array(); if (isset($gtafgid)){ $gtafInfo['group'] = DBUtil::selectObject('cataleg_gtafGroups','gtafGroupId="'.$gtafgid.'"'); } $gtafInfo['groups'] = DBUtil::selectFieldArray('cataleg_gtafGroups','gtafGroupId'); $grupsZikula = ModUtil::getVar("Cataleg", "grupsZikula"); $usercatlist = UserUtil::getUsersForGroup($grupsZikula['Sirius']); $users = UserUtil::getUsers('', 'uname', -1, -1, 'uid'); foreach ($users as $key => $user) { if (in_array($key, $usercatlist)) { $gtafInfo['catusers'][$key] = array('zk' => $user, 'iw' => DBUtil::selectObject('IWusers', 'where iw_uid =' . $key)); } } return $gtafInfo; }
public function detail($code) { $this->throwForbiddenUnless(SecurityUtil::checkPermission('Llicencies::', '::', ACCESS_READ)); $info = array(); if ($code) { $where = 'codi_treball='.$code; $info = DBUtil::selectObject('llicencies', $where); } return $info; }
/** * Load workflow for object. * * Will attach array '__WORKFLOW__' to the object. * * @param array &$obj Array object. * @param string $dbTable Database table. * @param string $idcolumn Id field, default = 'id'. * @param string $module Module name (defaults to current module). * * @return boolean */ public static function getWorkflowForObject(&$obj, $dbTable, $idcolumn = 'id', $module = null) { if (empty($module)) { $module = ModUtil::getName(); } if (!isset($obj) || !is_array($obj) && !is_object($obj)) { return z_exit(__f('%1$s: %2$s is not an array nor an object.', array('Zikula_Workflow_Util::getWorkflowForObject', 'object'))); } if (!isset($dbTable)) { return z_exit(__f('%1$s: %2$s is not specified.', array('Zikula_Workflow_Util::getWorkflowForObject', 'dbTable'))); } $workflow = false; if (!empty($obj[$idcolumn])) { // get workflow data from DB $dbtables = DBUtil::getTables(); $workflows_column = $dbtables['workflows_column']; $where = "WHERE {$workflows_column['module']} = '" . DataUtil::formatForStore($module) . "'\n AND {$workflows_column['obj_table']} = '" . DataUtil::formatForStore($dbTable) . "'\n AND {$workflows_column['obj_idcolumn']} = '" . DataUtil::formatForStore($idcolumn) . "'\n AND {$workflows_column['obj_id']} = '" . DataUtil::formatForStore($obj[$idcolumn]) . "'"; $workflow = DBUtil::selectObject('workflows', $where); } if (!$workflow) { $workflow = array('state' => 'initial', 'obj_table' => $dbTable, 'obj_idcolumn' => $idcolumn, 'obj_id' => $obj[$idcolumn]); } // attach workflow to object if ($obj instanceof Doctrine_Record) { $obj->mapValue('__WORKFLOW__', $workflow); } else { $obj['__WORKFLOW__'] = $workflow; } return true; }
/** * Add a message to the specified section item * @author Sara Arjona Téllez (sarjona@xtec.cat) * @param args array with the bean parameters * @return XML with the result of the callback */ public function beanaddmessage($args) { extract($args); if (!($assignment = DBUtil::selectObjectByID('IWqv_assignments', $assignmentid, 'qvaid'))) { $error = "error_assignmentid_does_not_exist"; } else { $pntable = DBUtil::getTables(); $c = $pntable['IWqv_sections_column']; $where = " $c[qvaid]=$assignmentid AND $c[sectionid]='$sectionid' "; if (!$section = DBUtil::selectObject('IWqv_sections', $where)) { // Insert section $section = array('qvaid' => $assignmentid, 'sectionid' => $sectionid); if (!($section = DBUtil::insertObject($section, 'IWqv_sections', 'qvsid'))) { $error = "error_db_insert"; } } if (!isset($error)) { // Insert message $message = array('qvsid' => $section[qvsid], 'itemid' => $itemid, 'userid' => $userid, 'message' => $message); if (!($qvmid = DBUtil::insertObject($message, 'IWqv_messages', 'qvmid'))) { $error = "error_db_insert"; } } } $response .= "<bean id=\"$beanid\" assignmentid=\"$assignmentid\" sectionid=\"$sectionid\" itemid=\"$itemid\" userid=\"$userid\" >"; $response .= " <message id=\"$qvmid\" "; if (isset($error)) $response .= " error=\"$error\" "; $response .= '/>'; $response .= '</bean>'; return $response; }
/** * Retrieve the user's new e-mail address that is awaiting his confirmation. * * @return string The e-mail address waiting for confirmation for the current user. * * @throws Zikula_Exception_Forbidden Thrown if the current user is logged in. */ public function getUserPreEmail() { if (!UserUtil::isLoggedIn()) { throw new Zikula_Exception_Forbidden(); } $dbinfo = DBUtil::getTables(); $verifychgColumn = $dbinfo['users_verifychg_column']; // delete all the records from e-mail confirmation that have expired $chgEmailExpireDays = $this->getVar(Users_Constant::MODVAR_EXPIRE_DAYS_CHANGE_EMAIL, Users_Constant::DEFAULT_EXPIRE_DAYS_CHANGE_EMAIL); if ($chgEmailExpireDays > 0) { $staleRecordUTC = new DateTime(null, new DateTimeZone('UTC')); $staleRecordUTC->modify("-{$chgEmailExpireDays} days"); $staleRecordUTCStr = $staleRecordUTC->format(Users_Constant::DATETIME_FORMAT); $where = "({$verifychgColumn['created_dt']} < '{$staleRecordUTCStr}') AND ({$verifychgColumn['changetype']} = " . Users_Constant::VERIFYCHGTYPE_EMAIL . ")"; DBUtil::deleteWhere ('users_verifychg', $where); } $uid = UserUtil::getVar('uid'); $item = DBUtil::selectObject('users_verifychg', "({$verifychgColumn['uid']} = {$uid}) AND ({$verifychgColumn['changetype']} = " . Users_Constant::VERIFYCHGTYPE_EMAIL . ")"); if (!$item) { return false; } return $item; }
function mediashare_invitationapi_getByKey($args) { $dom = ZLanguage::getModuleDomain('mediashare'); $key = DataUtil::formatForStore($args['key']); $pntable = pnDBGetTables(); $invitationColumn = $pntable['mediashare_invitation_column']; $where = " {$invitationColumn['key']} = '{$key}'\n AND ( {$invitationColumn['expires']} > NOW()\n OR {$invitationColumn['expires']} IS NULL)"; $invitation = DBUtil::selectObject('mediashare_invitation', $where); if ($invitation === false) { return LogUtil::registerError(__f('Error in %1$s: %2$s.', array('invitationapi.getByKey', 'Could not retrieve the invitation.'), $dom)); } return $invitation; }
/** * Torna array amb les dades de la unitat sol·licitada * * > Torna les valors de la unitat i, si **simple!=true**, a més, dos elements addicionals: * > **resp** -> array amb les dades de tots els responsables * > **numresp** -> nombre de responsables que té la unitat * * ### Paràmetres rebuts per GET: * * integer **uniId** Identificador d'unitat * * boolean **simple** * * @return array Informació sobre */ public function getUnitat($args) { //Verificar permisos $this->throwForbiddenUnless(SecurityUtil::checkPermission('Cataleg::', '::', ACCESS_READ)); $uniId = FormUtil::getPassedValue('uniId', isset($args['uniId']) ? $args['uniId'] : null, 'GET'); $simple = FormUtil::getPassedValue('simple', false, 'GET'); if (isset($uniId) && is_numeric($uniId)) { $where = 'uniId=' . $uniId; } else { $where = null; } $registre = DBUtil::selectObject('cataleg_unitats', $where); if ($registre === false) { return LogUtil::registerError($this->__('La consulta no ha obtingut cap resultat.')); } if (!$simple) { if (count($registre) > 0) { $where = " uniId= '" . $registre['uniId'] . "' "; $respon = DBUtil::selectObjectArray('cataleg_responsables', $where); if ($respon === false) { return LogUtil::registerError($this->__('La consulta no ha obtingut cap resultat.')); } foreach ($respon as $re) { $registre['resp'][] = array('responsable' => $re['responsable'], 'email' => $re['email'], 'telefon' => $re['telefon']); } $registre['numresp'] = count($respon); } else { return LogUtil::registerError($this->__('La consulta no ha obtingut cap resultat.')); } } return $registre; }
public function summary($args) { // get the last record in summary table $table = DBUtil::getTables(); $c = $table['IWstats_summary_column']; $d = $table['IWstats_column']; // get first record datetime $orderby = "$d[summarised] asc"; $last = DBUtil::selectObjectArray('IWstats', '', $orderby, -1, 1); $time = DateUtil::makeTimestamp($last[0]['datetime']); $toDateTimeStamp = $time + $args['days'] * 24 * 60 * 60; // calc the period $fromDate = date('d-m-Y', $time); $toDate = date('d-m-Y', $toDateTimeStamp); $records = ModUtil::apiFunc('IWstats', 'user', 'getAllRecords', array('fromDate' => $fromDate, 'toDate' => $toDate, 'all' => 1, )); $recordsArray = array(); foreach ($records as $record) { if (key_exists(substr($record['datetime'], 0, 10), $recordsArray)) { // add new information in array element $recordsArray[substr($record['datetime'], 0, 10)]['nRecords']++; if (($record['uid'] > 0)) $recordsArray[substr($record['datetime'], 0, 10)]['registered']++; if (key_exists($record['moduleid'], $recordsArray[substr($record['datetime'], 0, 10)]['users'][$record['uid']]['modules'])) { $recordsArray[substr($record['datetime'], 0, 10)]['users'][$record['uid']]['modules'][$record['moduleid']]++; } else { // add a new user in users array field $recordsArray[substr($record['datetime'], 0, 10)]['users'][$record['uid']]['modules'][$record['moduleid']] = 1; } if (key_exists($record['moduleid'], $recordsArray[substr($record['datetime'], 0, 10)]['modules'])) { $recordsArray[substr($record['datetime'], 0, 10)]['modules'][$record['moduleid']]++; } else { $recordsArray[substr($record['datetime'], 0, 10)]['modules'][$record['moduleid']] = 1; } if (($record['skipped'] == 1)) $recordsArray[substr($record['datetime'], 0, 10)]['skipped']++; if (($record['skippedModule'] == 1)) $recordsArray[substr($record['datetime'], 0, 10)]['skippedModule']++; if (($record['isadmin'] == 1)) $recordsArray[substr($record['datetime'], 0, 10)]['isadmin']++; if (!in_array($record['ip'], $recordsArray[substr($record['datetime'], 0, 10)]['ips'])) { $recordsArray[substr($record['datetime'], 0, 10)]['ips'][] = $record['ip']; } } else { // add a new element into the array $recordsArray[substr($record['datetime'], 0, 10)]['nRecords'] = 1; $recordsArray[substr($record['datetime'], 0, 10)]['registered'] = ($record['uid'] > 0) ? 1 : 0; $recordsArray[substr($record['datetime'], 0, 10)]['users'][$record['uid']]['modules'][$record['moduleid']] = 1; $recordsArray[substr($record['datetime'], 0, 10)]['ips'][] = $record['ip']; $recordsArray[substr($record['datetime'], 0, 10)]['datetime'] = substr($record['datetime'], 0, 10) . ' 00:00:00'; $recordsArray[substr($record['datetime'], 0, 10)]['modules'][$record['moduleid']] = 1; $recordsArray[substr($record['datetime'], 0, 10)]['skipped'] = ($record['skipped'] == 1) ? 1 : 0; $recordsArray[substr($record['datetime'], 0, 10)]['skippedModule'] = ($record['skippedModule'] == 1) ? 1 : 0; $recordsArray[substr($record['datetime'], 0, 10)]['isadmin'] = ($record['isadmin'] == 1) ? 1 : 0; } } ksort($recordsArray); // print_r($recordsArray);die(); // save records in ddbb foreach ($recordsArray as $record) { $usersArray = array(); foreach ($record['users'] as $key => $value) { $usersString = $key . '|'; $usersModulesArray = array(); foreach ($value['modules'] as $k => $v) { $usersModulesArray[] = $k . '=' . $v; } $usersModulesString = implode('#', $usersModulesArray); $usersArray[] = $usersString . $usersModulesString; } $users = '$' . implode('$$', $usersArray) . '$'; $modulesArray = array(); foreach ($record['modules'] as $key => $value) { $modulesArray[] = $key . '|' . $value; } $modules = '$' . implode('$$', $modulesArray) . '$'; $item = array( 'datetime' => $record['datetime'], 'nrecords' => $record['nRecords'], 'registered' => $record['registered'], 'modules' => $modules, 'skipped' => $record['skipped'], 'skippedModule' => $record['skippedModule'], 'isadmin' => $record['isadmin'], 'users' => $users, 'nips' => count($record['ips']), ); // checks if value exists in database. If exists update it. If not create it $summaryValue = DBUtil::selectObject('IWstats_summary', "$c[datetime]='$record[datetime]'"); if ($summaryValue) { if (!DBUtil::updateObject($item, 'IWstats_summary', "$c[datetime]='$record[datetime]'")) { return LogUtil::registerError($this->__('Error! Creation attempt failed.')); } } else { if (!DBUtil::insertObject($item, 'IWstats_summary')) { return LogUtil::registerError($this->__('Error! Creation attempt failed.')); } } $keepDays = $this->getVar('keepDays'); if (!is_numeric($keepDays) || $keepDays <= 0) $keepDays = 90; $time = time() - $keepDays * 24 * 60 * 60; $keepTime = date('Y-m-d 23:59:59', $time); $delDate = str_replace('00:00:00', '23:59:59', $record['datetime']); // set records as summarised $item = array('summarised' => 1); $where = "$d[datetime] <= '$delDate'"; DBUtil::updateObject($item, 'IWstats', $where); // delete old records $where = "$d[datetime] <= '$delDate' and $d[datetime] <= '$keepTime'"; DBUtil::deleteWhere('IWstats', $where); } return true; }
/** * Decrement sequence number of a permission. * * @param string $args ['type'] the type of the permission to decrement (user or group). * @param int $args ['pid'] the ID of the permission to decrement. * * @return boolean true on success, false on failure. */ public function dec($args) { // Security check if (!SecurityUtil::checkPermission('Permissions::', "group::{$args['pid']}", ACCESS_ADMIN)) { return LogUtil::registerPermissionError(); } // Argument check if (!isset($args['pid'])) { return LogUtil::registerArgsError(); } // Work out which tables to operate against $dbtable = DBUtil::getTables(); $permcolumn = $dbtable['group_perms_column']; if (!is_null($args['permgrp']) && $args['permgrp'] != SecurityUtil::PERMS_ALL) { $where = " AND ({$permcolumn['gid']}=" . SecurityUtil::PERMS_ALL . " OR {$permcolumn['gid']}='" . (int) DataUtil::formatForStore($args['permgrp']) . "')"; $showpartly = true; } else { $where = ''; $showpartly = false; } // Get info on current perm $result = DBUtil::selectObjectByID('group_perms', $args['pid'], 'pid'); if (!$result) { return LogUtil::registerError($this->__f('Error! Permission rule ID %s does not exist.', $args['pid'])); } $sequence = $result['sequence']; $maxsequence = $this->maxsequence(array('column' => 'sequence')); if ($sequence != $maxsequence) { $altsequence = $sequence + 1; // Get info on displaced perm // Filter-view: added extra check to select-query $where = "WHERE {$permcolumn['sequence']} = '" . (int) DataUtil::formatForStore($altsequence) . "' {$where}"; $result = DBUtil::selectObject('group_perms', $where); if (!$result) { if ($showpartly) { // Filter-view // Changing the sequence by moving while in partial view may only be done if there // are no invisible permissions inbetween that might be affected by the move. LogUtil::registerError($this->__('Error! Permission rule-swapping in partial view can only be done if both affected permission rules are visible. Please switch to full view.')); } else { LogUtil::registerError($this->__('Error! No permission rule directly below that one.')); } return false; } $altpid = $result['pid']; // Swap sequence numbers $where = "WHERE {$permcolumn['pid']} = '" . (int) DataUtil::formatForStore($altpid) . "'"; $obj = array('sequence' => $sequence); DBUtil::updateObject($obj, 'group_perms', $where, 'pid'); $where = "WHERE {$permcolumn['pid']} = '" . DataUtil::formatForStore($args['pid']) . "'"; $obj = array('sequence' => $altsequence); DBUtil::updateObject($obj, 'group_perms', $where, 'pid'); } return true; }
public function increaseIndent($args) { $pageId = (int) $args['pageId']; $page = DBUtil::selectObjectByID('content_page', $pageId); // Cannot indent topmost page if ($page['position'] == 0) { return true; } $parentPageId = $page['parentPageId']; $position = $page['position']; $dbtables = DBUtil::getTables(); $pageTable = $dbtables['content_page']; $pageColumn = $dbtables['content_page_column']; $where = "$pageColumn[parentPageId] = $parentPageId AND $pageColumn[position] = $position-1"; $previousPage = DBUtil::selectObject('content_page', $where); $thisPage = DBUtil::selectObjectByID('content_page', $pageId); if (!isset($previousPage['id']) || !isset($thisPage['urlname'])) { return LogUtil::registerError($this->__('Error! The indentation of this page cannot be increased.')); } $ok = $this->isUniqueUrlnameByParentID(array('urlname' => $thisPage['urlname'], 'parentId' => $previousPage['id'])); if (!$ok) { return LogUtil::registerError($this->__('Error! There is already another page registered with the supplied permalink URL.')); } $ok = $this->removePage(array('id' => $pageId)); if ($ok === false) { return false; } DBUtil::flushCache('content_page'); // Find new position (last in existing sub-pages) $sql = " SELECT MAX($pageColumn[position]) FROM $pageTable WHERE $pageColumn[parentPageId] = $previousPage[id]"; $newPosition = DBUtil::selectScalar($sql); if ($newPosition == null) { $newPosition = 0; } $ok = $this->insertPage(array('pageId' => $pageId, 'position' => $newPosition, 'parentPageId' => $previousPage['id'])); if ($ok === false) { return false; } /* $ok = $this->updateNestedSetValues(); if ($ok === false) return false; */ Content_Util::clearCache(); return true; }
/** * update the value addons tables */ public function updateValueAddons_104() { // Array of the modules to update $mods = array('News' => array('stories' => 'Main'), 'Pages' => array('pages' => 'Main'), 'FAQ' => array('faqanswer' => 'Main'), 'Feeds' => array('feeds' => 'Main'), 'Reviews' => array('reviews' => 'Main'), 'Content' => array('page' => 'primary')); $dbtables = DBUtil::getTables(); $regcol = $dbtables['categories_registry_column']; $mapcol = $dbtables['categories_mapobj_column']; // Update all the items mapped if there's a Register of the module foreach ($mods as $module => $data) { foreach ($data as $table => $property) { $where = "{$regcol['modname']}='{$module}' AND {$regcol['table']}='{$table}' AND {$regcol['property']}='{$property}'"; $reg_id = DBUtil::selectObject('categories_registry', $where, array('id')); if ($reg_id !== false) { $obj = array('reg_id' => $reg_id['id']); $where = "{$mapcol['modname']}='{$module}' AND {$mapcol['table']}='{$table}'"; DBUtil::updateObject($obj, 'categories_mapobj', $where, 'sid'); } } } return true; }
public function get_bookingInfo($args) { $result = array(); if (!SecurityUtil::checkPermission('IWbookings::', '::', ACCESS_READ)) { return $result; } $bid = FormUtil::getPassedValue('bid', isset($args['bid']) ? $args['bid'] : null, 'GET'); $pntable = DBUtil::getTables(); $c = $pntable['IWbookings_column']; $bInfo = DBUtil::selectObject('IWbookings', "$c[bid]=" . $bid); $result = $bInfo; $rs = DBUtil::selectObjectArray('IWbookings', "$c[bkey]=" . $bInfo['bkey'], 'bid'); $result['count'] = count($rs) - 1; // Num grouped bookings return $result; }