public function index() { $post = array('alert' => ''); // Model::load('admincp/setting'); if ($match = Uri::match('\\/setting\\/(\\w+)')) { if (method_exists("controlSetting", $match[1])) { $method = $match[1]; $this->{$method}(); die; } } if (Request::has('btnSave')) { System::saveSetting(Request::get('general')); } $data = array(); if (!($data = Cache::loadKey('systemSetting', -1))) { $data = System::makeSetting(); } else { $data = unserialize($data); } $post = $data; $post['usergroups'] = UserGroups::get(); System::setTitle('Setting System - ' . ADMINCP_TITLE); View::make('admincp/head'); self::makeContents('settingGeneral', $post); View::make('admincp/footer'); }
public function test_get() { // test 'fetch_fn' $this->mark_test_incomplete(); // test 'count' $this->assert_equal(count(UserGroups::get_all()), UserGroups::get(array('count' => true))); // test 'limit' $this->assert_equal(count(UserGroups::get(array('limit' => 1))), 1); // test 'offset' $this->assert_equal(count(UserGroups::get(array('limit' => 1, 'offset' => 1))), 1); $this->assert_not_equal(UserGroups::get(array('limit' => 1, 'offset' => 1)), UserGroups::get(array('limit' => 1)), 1); // test 'where', including an 'id'... }
function insertProcess() { $send = Request::get('send'); $valid = Validator::make(array('send.group_title' => 'min:1|slashes', 'send.groupdata' => 'min:1|slashes')); if (!$valid) { throw new Exception("Error Processing Request"); } $title = trim(Request::get('send.group_title')); $loadData = UserGroups::get(array('where' => "where group_title='{$title}'")); if (isset($loadData[0]['groupdata'])) { throw new Exception("This group have been exists."); } $content = trim(Request::get('send.groupdata')); $insertData = array('group_title' => $title, 'groupdata' => $content); UserGroups::insert($insertData); }
public function action_form_publish_proposal($form, $post) { $users = Users::get_all(); $client_options = array(); foreach ($users as $user) { if ($user->client) { $client_options[$user->id] = $user->client->title . ' : ' . $user->displayname; } } $form->insert('content', new FormControlSelect('client_contact', $post, 'Client Contact', $client_options, 'admincontrol_select')); $group = UserGroups::get(array('id' => Options::get('staff__group'), 'fetch_fn' => 'get_row')); $user_options = array(); foreach ($group->users as $user) { $user_options[$user->id] = $user->displayname; } $form->insert('content', new FormControlSelect('staff', $post, 'Staff', $user_options, 'admincontrol_select')); }
public function edit() { if (!($match = Uri::match('\\/edit\\/(\\d+)'))) { Redirect::to(ADMINCP_URL . 'usergroups/'); } $groupid = $match[1]; $post = array('alert' => ''); if (Request::has('btnSave')) { try { updateProcess($groupid); $post['alert'] = '<div class="alert alert-success">Save changes success.</div>'; } catch (Exception $e) { $post['alert'] = '<div class="alert alert-warning">' . $e->getMessage() . '</div>'; } } $loadData = UserGroups::get(array('where' => "where groupid='{$groupid}'")); $post['edit'] = $loadData[0]; System::setTitle('Edit group - ' . ADMINCP_TITLE); View::make('admincp/head'); self::makeContents('usergroupsEdit', $post); View::make('admincp/footer'); }
public static function changeGroup($userid, $groupid) { $getData = UserGroups::get(array('where' => "where groupid='{$groupid}'")); if (!isset($getData[0]['groupid'])) { return false; } self::update($userid, array('groupid' => $groupid)); return true; }
public function profile() { $post = array('alert' => ''); $match = Uri::match('\\/profile$'); $userid = Users::getCookieUserId(); if (Request::has('btnSave')) { try { updateProcess($userid); $post['alert'] = '<div class="alert alert-success">Save changes success.</div>'; } catch (Exception $e) { $post['alert'] = '<div class="alert alert-warning">' . $e->getMessage() . '</div>'; } } if (Request::has('btnChangePassword')) { Users::changePassword($userid, Request::get('password', '')); } $prefix = ''; $prefixall = Database::isPrefixAll(); if ($prefixall != false || $prefixall == 'no') { $prefix = Database::getPrefix(); } $loadData = Users::get(array('query' => "select u.*,ug.*,a.* from " . $prefix . "users u," . $prefix . "usergroups ug," . $prefix . "address a where u.groupid=ug.groupid AND u.userid=a.userid AND u.userid='{$userid}' order by u.userid desc")); $post['edit'] = $loadData[0]; $post['listGroups'] = UserGroups::get(); System::setTitle('Profile - ' . ADMINCP_TITLE); View::make('admincp/head'); self::makeContents('userEdit', $post); View::make('admincp/footer'); }