/** * delete session file with given perm name * @param [type] $_permName [description] * @param boolean $_exceptMe [description] * @return [type] [description] */ public static function deleteByPerm($_permName) { $permList = \lib\utility\option::permList(true); $deleteResult = []; // if permission exist if (isset($permList[$_permName])) { // find user with this permission $perm_id = $permList[$_permName]; // connect to database \lib\db::connect(true); $qry = "SELECT `options`.option_value\n\t\t\t\tFROM users\n\t\t\t\tINNER JOIN `options` ON `options`.user_id = `users`.id\n\t\t\t\tWHERE `options`.option_cat = 'session' AND\n\t\t\t\t\tuser_permission = {$perm_id};"; // run query and give result $result = @mysqli_query(\lib\db::$link, $qry); // fetch all records $result = \lib\db::fetch_all($result, 'option_value'); if ($result) { $deleteResult = self::delete($result); // for each file in delete foreach ($deleteResult as $key => $value) { // if file is deleted if ($value === true) { $qry = "DELETE FROM options WHERE option_cat = 'session' AND option_value = '{$key}';"; @mysqli_query(\lib\db::$link, $qry); } } return $deleteResult; } } return null; }
function draw_users() { $mychild = $this->child(); $this->data->form->users->user_status->required('required'); $checkStatus = null; $myPerm = null; $myPermNames = \lib\utility\option::permList(); $myPermList = $this->data->form->users->user_permission; if (count($myPermNames) > 5) { $myPermList->type('select'); $checkStatus = 'selected'; } else { $myPermList->type('radio'); $checkStatus = 'checked'; } if ($mychild === 'edit') { $myPerm = $this->model()->datarow('users'); $myPerm = $myPerm['user_permission']; if ($myPerm === "1") { $myPermList->addClass('hide'); } } // get list of permissions foreach ($myPermNames as $key => $value) { if ($myPerm == $key) { $myPermList->child()->value($key)->label(T_($value))->elname(null)->pl(null)->attr('type', null)->id('perm' . $key)->{$checkStatus}(); } else { $myPermList->child()->value($key)->label(T_($value))->elname(null)->pl(null)->attr('type', null)->id('perm' . $key); } } $this->data->form->users->user_pass->autocomplete('new-password'); $myPass = $this->data->form->users->user_pass; if ($mychild === 'add') { $myPass->attr('required', 'required')->pl(T_('Enter password within 5 to 40 character')); } else { $myPass->label(T_('New Password'))->value(null)->pl(T_('If you want to change password enter it, else leave it blank')); } // get user position and set it $position = null; if (isset($this->data->form->users->datarow['user_meta'])) { $meta = $this->data->form->users->datarow['user_meta']; $meta = json_decode($meta, true); if (isset($meta['position'])) { $position = $meta['position']; } } $this->data->form->users->add('position', 'text')->name('position')->label(T_("position"))->value($position)->compile(); $this->data->form->users->after('position', 'user_displayname'); }
function view_datatable() { $form_general = $this->createform('.options', 'general', true); $form_config = $this->createform('.options', 'config', true); $form_social = $this->createform('.options', 'social', true); $form_twitter = $this->createform('.options', 'twitter', true); $form_facebook = $this->createform('.options', 'facebook', true); $form_telegram = $this->createform('.options', 'telegram', true); $form_sms = $this->createform('.options', 'sms', true); $form_register = $this->createform('.options', 'account', true); // add languages item foreach (\lib\utility\option::languages() as $key => $value) { $form_config->config_defaultLang->child()->id('lang_' . $key)->value($key)->label($value); } // add sms items $form_sms->sms_name->child()->id('sms_kavenegar')->value('kavenegar_api')->label(T_('Kavenegar')); $tld_list = ['com', 'org', 'edu', 'net', 'ir']; foreach ($tld_list as $key => $tld) { $form_config->config_defaultTld->child()->id('config_tld_' . $tld)->value($tld)->label($tld); } // add content list to show for redirect foreach (\lib\utility\option::contentList(true) as $key => $value) { $form_register->account_redirect->child()->id('redirect_' . $key)->value($value)->label(T_($value)); } // give perm list and fill it in default register type $myPermList = $form_register->account_default; $myPermNames = \lib\utility\option::permList(); if (!$myPermNames) { $myPermNames = []; } $myPerm = 1; // if list of permission is more than 6 item show in select if (count($myPermNames) > 6) { $myPermList = $form_register->account_default->type('select'); } // get list of permissions foreach ($myPermNames as $key => $value) { if ($myPerm == $key) { $myPermList->child()->value($key)->label(T_($value))->elname(null)->pl(null)->attr('type', null)->id('perm_' . $key)->selected(); } else { $myPermList->child()->value($key)->label(T_($value))->elname(null)->pl(null)->attr('type', null)->id('perm_' . $key); } } // get the datatable of options $datatable = $this->model()->draw_options(); // $datatable['sms']['sms'] = null; // fill all forms used in options page if (isset($datatable['general'])) { $this->form_fill($form_general, $datatable['general']); } if (isset($datatable['config']['config'])) { $this->form_fill($form_config, $datatable['config']['config']); // add default tld to domain name if (isset($datatable['config']['config']['meta']['defaultTld'])) { $selectedTld = $datatable['config']['config']['meta']['defaultTld']; $form_config->config_domainName->attr('data-after', $selectedTld); } } if (isset($datatable['social'])) { $this->form_fill($form_social, $datatable['social']); } if (isset($datatable['social']['twitter'])) { $this->form_fill($form_twitter, $datatable['social']['twitter']); } if (isset($datatable['social']['facebook'])) { $this->form_fill($form_facebook, $datatable['social']['facebook']); } if (isset($datatable['social']['telegram'])) { $this->form_fill($form_telegram, $datatable['social']['telegram']); } if (isset($datatable['sms']['sms'])) { $this->form_fill($form_sms, $datatable['sms']['sms']); } if (isset($datatable['account']['account'])) { $this->form_fill($form_register, $datatable['account']['account']); } }