Exemplo n.º 1
0
 public function testThatFetchingDataFromDbWillStoreItInCacheForLaterUseUnderCacheIdContainingAtLeastMethodName()
 {
     $userModel = new Users(array('db' => $this->db, 'cache' => $this->cache));
     $users = $userModel->getAll();
     foreach ($userModel->getCache()->getIds() as $cacheId) {
         // strpos will return boolean false if don't find Users__getAll substring in $cacheId
         if (strpos($cacheId, 'Users__getAll') !== false) {
             $this->assertEquals($users, $userModel->getCache()->load($cacheId));
             break;
         }
     }
 }
Exemplo n.º 2
0
 public function actionConfirm()
 {
     $this->view->data['header'] = 'Договор';
     $this->view->data['kyrjers'] = Users::getAll('fio', array('status' => 'kyrjer'));
     $this->view->data['districts'] = Numbers::getAll('DISTINCT `district`');
     $this->view->content = array('confirm');
     if ($this->view->data['numbers'] = $this->model->confirmTable()) {
         $this->view->notice['notice'] .= 'Номера извлечены. ';
     } else {
         $this->view->notice['error'] .= $this->model->error;
     }
     if (!empty($_GET['unload'])) {
         $this->view->htmlResponse('unload', 'main');
     } else {
         $this->view->generate();
     }
 }
Exemplo n.º 3
0
/**
 * Render select user box
 *
 * @param integer $selected ID of selected user
 * @param array $attributes Additional attributes
 * @return string
 */
function select_user($name, $selected = null, $attributes = null)
{
    $users = Users::getAll();
    $options = array(option_tag(lang('none'), 0));
    if (is_array($users)) {
        foreach ($users as $user) {
            $option_attributes = $user->getId() == $selected ? array('selected' => 'selected') : null;
            $user_name = $user->getUsername();
            if ($user->isAdministrator()) {
                $user_name .= ' (' . lang('administrator') . ')';
            }
            $options[] = option_tag($user_name, $user->getId(), $option_attributes);
        }
        // foreach
    }
    // if
    return select_box($name, $options, $attributes);
}
Exemplo n.º 4
0
 /**
  * Page
  */
 public function usersAction()
 {
     $usersModel = new Users();
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         if (@$data['method'] == 'create') {
             //CREATE NEW USER
             unset($data['method']);
             if ($data['email'] == '' || $data['password'] == '') {
                 $this->view->error = "Please complete all fields.";
                 $this->view->data = $data;
             } else {
                 $data['password'] = sha1($data['password']);
                 $usersModel->insert($data);
                 $this->view->success = "New User Created.";
             }
         }
         if (@$data['method'] == 'update') {
             //UPDATE USER
             unset($data['method']);
             if ($data['password'] == '') {
                 unset($data['password']);
             } else {
                 $data['password'] = sha1($data['password']);
             }
             $usersModel->updateRecord($data['id'], $data);
             $this->view->success = "User Record Updated.";
         }
         if (@$data['method'] == 'delete') {
             //DELETE USER
             $where = "id=" . $data['id'];
             $usersModel->delete($where);
         }
     }
     $users = $usersModel->getAll();
     $page = $this->_getParam('page', 1);
     $paginator = Zend_Paginator::factory($users);
     $paginator->setItemCountPerPage(20);
     $paginator->setCurrentPageNumber($page);
     $this->view->users = $paginator;
     $locationsModel = new Locations();
     $this->view->locations = $locationsModel->getAll();
 }
Exemplo n.º 5
0
 public function get_index()
 {
     $users = Users::getAll();
     return View::make('admin/users.index')->with('users', $users);
 }
Exemplo n.º 6
0
 private function manageUsers()
 {
     /* Bail out if the user doesn't have SA permissions. */
     if ($this->_realAccessLevel < ACCESS_LEVEL_DEMO) {
         CommonErrors::fatal(COMMONERROR_PERMISSION, $this);
         return;
         //$this->fatal(ERROR_NO_PERMISSION);
     }
     $users = new Users($this->_siteID);
     $rs = $users->getAll();
     $license = $users->getLicenseData();
     foreach ($rs as $rowIndex => $row) {
         $rs[$rowIndex]['successfulDate'] = DateUtility::fixZeroDate($rs[$rowIndex]['successfulDate'], 'Never');
         $rs[$rowIndex]['unsuccessfulDate'] = DateUtility::fixZeroDate($rs[$rowIndex]['unsuccessfulDate'], 'Never');
         // FIXME: The last test here might be redundant.
         // FIXME: Put this in a private method. It is duplicated twice so far.
         $siteIDPosition = strpos($row['username'], '@' . $_SESSION['CATS']->getSiteID());
         if ($siteIDPosition !== false && substr($row['username'], $siteIDPosition) == '@' . $_SESSION['CATS']->getSiteID()) {
             $rs[$rowIndex]['username'] = str_replace('@' . $_SESSION['CATS']->getSiteID(), '', $row['username']);
         }
     }
     $this->_template->assign('active', $this);
     $this->_template->assign('subActive', 'User Management');
     $this->_template->assign('rs', $rs);
     $this->_template->assign('license', $license);
     $this->_template->display('./modules/settings/Users.tpl');
 }
 function new_list_tasks()
 {
     //load config options into cache for better performance
     load_user_config_options_by_category_name('task panel');
     // get query parameters, save user preferences if necessary
     $status = array_var($_GET, 'status', null);
     if (is_null($status) || $status == '') {
         $status = user_config_option('task panel status', 2);
     } else {
         if (user_config_option('task panel status') != $status) {
             set_user_config_option('task panel status', $status, logged_user()->getId());
         }
     }
     $previous_filter = user_config_option('task panel filter', 'assigned_to');
     $filter = array_var($_GET, 'filter');
     if (is_null($filter) || $filter == '') {
         $filter = user_config_option('task panel filter', 'assigned_to');
     } else {
         if (user_config_option('task panel filter') != $filter) {
             set_user_config_option('task panel filter', $filter, logged_user()->getId());
         }
     }
     if ($filter != 'no_filter') {
         $filter_value = array_var($_GET, 'fval');
         if (is_null($filter_value) || $filter_value == '') {
             $filter_value = user_config_option('task panel filter value', logged_user()->getCompanyId() . ':' . logged_user()->getId());
             set_user_config_option('task panel filter value', $filter_value, logged_user()->getId());
             $filter = $previous_filter;
             set_user_config_option('task panel filter', $filter, logged_user()->getId());
         } else {
             if (user_config_option('task panel filter value') != $filter_value) {
                 set_user_config_option('task panel filter value', $filter_value, logged_user()->getId());
             }
         }
     }
     $isJson = array_var($_GET, 'isJson', false);
     if ($isJson) {
         ajx_current("empty");
     }
     $project = active_project();
     $tag = active_tag();
     $template_condition = "`is_template` = 0 ";
     //Get the task query conditions
     $task_filter_condition = "";
     switch ($filter) {
         case 'assigned_to':
             $assigned_to = explode(':', $filter_value);
             $assigned_to_user = array_var($assigned_to, 1, 0);
             $assigned_to_company = array_var($assigned_to, 0, 0);
             if ($assigned_to_user > 0) {
                 $task_filter_condition = " AND (`assigned_to_user_id` = " . $assigned_to_user . " OR (`assigned_to_company_id` = " . $assigned_to_company . " AND `assigned_to_user_id` = 0)) ";
             } else {
                 if ($assigned_to_company > 0) {
                     $task_filter_condition = " AND  `assigned_to_company_id` = " . $assigned_to_company . " AND `assigned_to_user_id` = 0";
                 } else {
                     if ($assigned_to_company == -1 && $assigned_to_user == -1) {
                         $task_filter_condition = "  AND `assigned_to_company_id` = 0 AND `assigned_to_user_id` = 0 ";
                     }
                 }
             }
             break;
         case 'assigned_by':
             if ($filter_value != 0) {
                 $task_filter_condition = " AND  `assigned_by_id` = " . $filter_value . " ";
             }
             break;
         case 'created_by':
             if ($filter_value != 0) {
                 $task_filter_condition = " AND  `created_by_id` = " . $filter_value . " ";
             }
             break;
         case 'completed_by':
             if ($filter_value != 0) {
                 $task_filter_condition = " AND  `completed_by_id` = " . $filter_value . " ";
             }
             break;
         case 'milestone':
             $task_filter_condition = " AND  `milestone_id` = " . $filter_value . " ";
             break;
         case 'priority':
             $task_filter_condition = " AND  `priority` = " . $filter_value . " ";
             break;
         case 'subtype':
             if ($filter_value != 0) {
                 $task_filter_condition = " AND  `object_subtype` = " . $filter_value . " ";
             }
             break;
         case 'no_filter':
             $task_filter_condition = "";
             break;
         default:
             flash_error(lang('task filter criteria not recognised', $filter));
     }
     if ($project instanceof Project) {
         $pids = $project->getAllSubWorkspacesQuery(true);
         $projectstr = " AND " . ProjectTasks::getWorkspaceString($pids);
     } else {
         $pids = "";
         $projectstr = "";
     }
     $permissions = " AND " . permissions_sql_for_listings(ProjectTasks::instance(), ACCESS_LEVEL_READ, logged_user());
     $task_status_condition = "";
     switch ($status) {
         case 0:
             // Incomplete tasks
             $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME);
             break;
         case 1:
             // Complete tasks
             $task_status_condition = " AND `completed_on` > " . DB::escape(EMPTY_DATETIME);
             break;
         case 10:
             // Active tasks
             $now = date('Y-m-j 00:00:00');
             $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `start_date` <= '{$now}'";
             break;
         case 11:
             // Overdue tasks
             $now = date('Y-m-j 00:00:00');
             $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `due_date` < '{$now}'";
             break;
         case 12:
             // Today tasks
             $now = date('Y-m-j 00:00:00');
             $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `due_date` = '{$now}'";
             break;
         case 13:
             // Today + Overdue tasks
             $now = date('Y-m-j 00:00:00');
             $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `due_date` <= '{$now}'";
             break;
         case 14:
             // Today + Overdue tasks
             $now = date('Y-m-j 00:00:00');
             $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `due_date` <= '{$now}'";
             break;
         case 20:
             // Actives task by current user
             $now = date('Y-m-j 00:00:00');
             $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `start_date` <= '{$now}' AND `assigned_to_user_id` = " . logged_user()->getId();
             break;
         case 21:
             // Subscribed tasks by current user
             $res20 = DB::execute("SELECT object_id FROM " . TABLE_PREFIX . "object_subscriptions WHERE `object_manager` LIKE 'ProjectTasks' AND `user_id` = " . logged_user()->getId());
             $subs_rows = $res20->fetchAll($res20);
             foreach ($subs_rows as $row) {
                 $subs[] = $row['object_id'];
             }
             unset($res20, $subs_rows, $row);
             $now = date('Y-m-j 00:00:00');
             $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `id` IN(" . implode(',', $subs) . ")";
             break;
         case 2:
             // All tasks
             break;
         default:
             throw new Exception('Task status "' . $status . '" not recognised');
     }
     if (!$tag) {
         $tagstr = "";
     } else {
         $tagstr = " AND (select count(*) from " . TABLE_PREFIX . "tags where " . TABLE_PREFIX . "project_tasks.id = " . TABLE_PREFIX . "tags.rel_object_id and " . TABLE_PREFIX . "tags.tag = " . DB::escape($tag) . " and " . TABLE_PREFIX . "tags.rel_object_manager ='ProjectTasks' ) > 0 ";
     }
     $conditions = $template_condition . $task_filter_condition . $task_status_condition . $permissions . $tagstr . $projectstr . " AND `trashed_by_id` = 0 AND `archived_by_id` = 0";
     //Now get the tasks
     $tasks = ProjectTasks::findAll(array('conditions' => $conditions, 'order' => 'created_on DESC', 'limit' => user_config_option('task_display_limit') > 0 ? user_config_option('task_display_limit') + 1 : null));
     ProjectTasks::populateData($tasks);
     //Find all internal milestones for these tasks
     $internalMilestones = ProjectMilestones::getProjectMilestones(active_or_personal_project(), null, 'DESC', "", null, null, null, $status == 0, false);
     ProjectMilestones::populateData($internalMilestones);
     //Find all external milestones for these tasks
     $milestone_ids = array();
     if ($tasks) {
         foreach ($tasks as $task) {
             if ($task->getMilestoneId() != 0) {
                 $milestone_ids[$task->getMilestoneId()] = $task->getMilestoneId();
             }
         }
     }
     $milestone_ids_condition = '';
     if (count($milestone_ids) > 0) {
         $milestone_ids_condition = ' OR id in (' . implode(',', $milestone_ids) . ')';
     }
     if ($status == 0) {
         $pendingstr = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " ";
     } else {
         $pendingstr = "";
     }
     if (!$tag) {
         $tagstr = "";
     } else {
         $tagstr = " AND (select count(*) from " . TABLE_PREFIX . "tags where " . TABLE_PREFIX . "project_milestones.id = " . TABLE_PREFIX . "tags.rel_object_id and " . TABLE_PREFIX . "tags.tag = " . DB::escape($tag) . " and " . TABLE_PREFIX . "tags.rel_object_manager ='ProjectMilestones' ) > 0 ";
     }
     $projectstr = " AND (" . ProjectMilestones::getWorkspaceString($pids) . $milestone_ids_condition . ")";
     $archivedstr = " AND `archived_by_id` = 0 ";
     $milestone_conditions = " `is_template` = false " . $archivedstr . $projectstr . $pendingstr;
     $externalMilestonesTemp = ProjectMilestones::findAll(array('conditions' => $milestone_conditions));
     $externalMilestones = array();
     if ($externalMilestonesTemp) {
         foreach ($externalMilestonesTemp as $em) {
             $found = false;
             if ($internalMilestones) {
                 foreach ($internalMilestones as $im) {
                     if ($im->getId() == $em->getId()) {
                         $found = true;
                         break;
                     }
                 }
             }
             if (!$found) {
                 $externalMilestones[] = $em;
             }
         }
     }
     ProjectMilestones::populateData($externalMilestones);
     //Get Users Info
     if (logged_user()->isMemberOfOwnerCompany()) {
         $users = Users::getAll();
         $allUsers = array();
     } else {
         $users = logged_user()->getAssignableUsers();
         $allUsers = Users::getAll();
     }
     //Get Companies Info
     if (logged_user()->isMemberOfOwnerCompany()) {
         $companies = Companies::getCompaniesWithUsers();
     } else {
         $companies = logged_user()->getAssignableCompanies();
     }
     if (!$isJson) {
         if (active_project() instanceof Project) {
             $task_templates = WorkspaceTemplates::getTemplatesByWorkspace(active_project()->getId());
         } else {
             $task_templates = array();
         }
         tpl_assign('project_templates', $task_templates);
         tpl_assign('all_templates', COTemplates::findAll());
         if (user_config_option('task_display_limit') > 0 && count($tasks) > user_config_option('task_display_limit')) {
             tpl_assign('displayTooManyTasks', true);
             array_pop($tasks);
         }
         tpl_assign('tasks', $tasks);
         tpl_assign('object_subtypes', ProjectCoTypes::getObjectTypesByManager('ProjectTasks'));
         tpl_assign('internalMilestones', $internalMilestones);
         tpl_assign('externalMilestones', $externalMilestones);
         tpl_assign('users', $users);
         tpl_assign('allUsers', $allUsers);
         tpl_assign('companies', $companies);
         tpl_assign('userPreferences', array('filterValue' => isset($filter_value) ? $filter_value : '', 'filter' => $filter, 'status' => $status, 'showWorkspaces' => user_config_option('tasksShowWorkspaces', 1), 'showTime' => user_config_option('tasksShowTime', 0), 'showDates' => user_config_option('tasksShowDates', 0), 'showTags' => user_config_option('tasksShowTags', 0), 'showEmptyMilestones' => user_config_option('tasksShowEmptyMilestones', 0), 'groupBy' => user_config_option('tasksGroupBy', 'milestone'), 'orderBy' => user_config_option('tasksOrderBy', 'priority'), 'defaultNotifyValue' => user_config_option('can notify from quick add')));
         ajx_set_no_toolbar(true);
     }
 }
Exemplo n.º 8
0
                            Poslednjih 10 korisnika
                        </div>
                        <div class="panel-body">
                            <div class="table-responsive">
                                <table class="table table-striped table-bordered table-hover">
                                    <thead>
                                        <tr>
                                            <th>#</th>
                                            <th>Ime</th>
                                            <th>Telefon</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                            <?php 
/**************************************************************************************************/
$last_ten_user = Users::getAll("ORDER BY user_id DESC LIMIT 10");
foreach ($last_ten_user as $user) {
    echo "<tr> \n                                       <td>{$user->user_id} </td>\n                                       <td>{$user->user_name} {$user->user_surname}</td>\n                                       <td>{$user->user_phone}</td>\n                                    </tr>";
}
/******************************************************************************************************/
?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
         </div>
                     <!-- End  Kitchen Sink -->
                        <!--   Kitchen Sink -->
      <div class="col-md-6">
                    <div class="panel panel-default">
Exemplo n.º 9
0
 public function home()
 {
     $users = Users::getAll();
     print_r($users);
     require_once 'views/pages/home.php';
 }
Exemplo n.º 10
0
 function index()
 {
     if (!can_manage_time(logged_user(), true)) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $tasksUserId = array_var($_GET, 'tu');
     if (is_null($tasksUserId)) {
         $tasksUserId = user_config_option('TM tasks user filter', logged_user()->getId());
     } else {
         if (user_config_option('TM tasks user filter') != $tasksUserId) {
             set_user_config_option('TM tasks user filter', $tasksUserId, logged_user()->getId());
         }
     }
     $timeslotsUserId = array_var($_GET, 'tsu');
     if (is_null($timeslotsUserId)) {
         $timeslotsUserId = user_config_option('TM user filter', 0);
     } else {
         if (user_config_option('TM user filter') != $timeslotsUserId) {
             set_user_config_option('TM user filter', $timeslotsUserId, logged_user()->getId());
         }
     }
     $showTimeType = array_var($_GET, 'stt');
     if (is_null($showTimeType)) {
         $showTimeType = user_config_option('TM show time type', 0);
     } else {
         if (user_config_option('TM show time type') != $showTimeType) {
             set_user_config_option('TM show time type', $showTimeType, logged_user()->getId());
         }
     }
     $start = array_var($_GET, 'start', 0);
     $limit = 20;
     $tasksUser = Users::findById($tasksUserId);
     $timeslotsUser = Users::findById($timeslotsUserId);
     //Active tasks view
     $tasks = ProjectTasks::getOpenTimeslotTasks($tasksUser, logged_user());
     ProjectTasks::populateData($tasks);
     $tasks_array = array();
     //Timeslots view
     $total = 0;
     switch ($showTimeType) {
         case 0:
             //Show only timeslots added through the time panel
             $timeslots = Timeslots::getProjectTimeslots(logged_user()->getWorkspacesQuery(), $timeslotsUser, active_project(), $start, $limit);
             $total = Timeslots::countProjectTimeslots(logged_user()->getWorkspacesQuery(), $timeslotsUser, active_project());
             break;
         case 1:
             //Show only timeslots added through the tasks panel / tasks
             throw new Error('not yet implemented' . $showTimeType);
             /*if (active_project() instanceof Project){
             			$workspacesCSV = active_project()->getAllSubWorkspacesQuery(false,logged_user());
             		} else {
             			$workspacesCSV = logged_user()->getWorkspacesQuery();
             		}
             		$taskTimeslots = Timeslots::getTaskTimeslots(null, $timeslotsUser, $workspacesCSV, null , null, null, null,0,20);*/
             //break;
         /*if (active_project() instanceof Project){
         			$workspacesCSV = active_project()->getAllSubWorkspacesQuery(false,logged_user());
         		} else {
         			$workspacesCSV = logged_user()->getWorkspacesQuery();
         		}
         		$taskTimeslots = Timeslots::getTaskTimeslots(null, $timeslotsUser, $workspacesCSV, null , null, null, null,0,20);*/
         //break;
         case 2:
             //Show timeslots added through both the time and tasks panel / tasks
             throw new Error('not yet implemented' . $showTimeType);
             //break;
         //break;
         default:
             throw new Error('Unrecognised TM show time type: ' . $showTimeType);
     }
     //Get Users Info
     if (logged_user()->isMemberOfOwnerCompany()) {
         $users = Users::getAll();
     } else {
         $users = logged_user()->getCompany()->getUsers();
     }
     //Get Companies Info
     if (logged_user()->isMemberOfOwnerCompany()) {
         $companies = Companies::getCompaniesWithUsers();
     } else {
         $companies = array(logged_user()->getCompany());
     }
     tpl_assign('timeslots', $timeslots);
     tpl_assign('tasks', $tasks);
     tpl_assign('users', $users);
     tpl_assign('start', $start);
     tpl_assign('limit', $limit);
     tpl_assign('total', $total);
     tpl_assign('companies', $companies);
     ajx_set_no_toolbar(true);
 }
Exemplo n.º 11
0
 public function getOwnersByType($data)
 {
     $this->setResponseType('json');
     $result = new stdclass();
     $result->status = 'OK';
     try {
         switch ($data->type) {
             case 'EVERYBODY':
                 $result->total = 0;
                 $result->owners = array();
                 break;
             case 'USER':
                 require_once 'classes/model/Users.php';
                 $users = array();
                 $usersInstance = new Users();
                 $allUsers = $usersInstance->getAll();
                 foreach ($allUsers->data as $user) {
                     $users[] = array('OWNER_UID' => $user['USR_UID'], 'OWNER_NAME' => $user['USR_FIRSTNAME'] . ' ' . $user['USR_LASTNAME']);
                 }
                 usort($users, function ($str1, $str2) {
                     return strcmp(strtolower($str1["OWNER_NAME"]), strtolower($str2["OWNER_NAME"]));
                 });
                 $result->total = $allUsers->totalCount;
                 $result->owners = $users;
                 break;
             case 'DEPARTMENT':
                 require_once 'classes/model/Department.php';
                 require_once 'classes/model/Content.php';
                 $departments = array();
                 //SELECT
                 $criteria = new Criteria('workflow');
                 $criteria->setDistinct();
                 $criteria->addSelectColumn(DepartmentPeer::DEP_UID);
                 $criteria->addSelectColumn(ContentPeer::CON_VALUE);
                 //FROM
                 $conditions = array();
                 $conditions[] = array(DepartmentPeer::DEP_UID, ContentPeer::CON_ID);
                 $conditions[] = array(ContentPeer::CON_CATEGORY, DBAdapter::getStringDelimiter() . 'DEPO_TITLE' . DBAdapter::getStringDelimiter());
                 $conditions[] = array(ContentPeer::CON_LANG, DBAdapter::getStringDelimiter() . 'en' . DBAdapter::getStringDelimiter());
                 $criteria->addJoinMC($conditions, Criteria::LEFT_JOIN);
                 //WHERE
                 $criteria->add(DepartmentPeer::DEP_STATUS, 'ACTIVE');
                 //ORDER BY
                 $criteria->addAscendingOrderByColumn(ContentPeer::CON_VALUE);
                 $dataset = DepartmentPeer::doSelectRS($criteria);
                 $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
                 $dataset->next();
                 while ($row = $dataset->getRow()) {
                     $departments[] = array('OWNER_UID' => $row['DEP_UID'], 'OWNER_NAME' => $row['CON_VALUE']);
                     $dataset->next();
                 }
                 $result->total = DepartmentPeer::doCount($criteria);
                 $result->owners = $departments;
                 break;
             case 'GROUP':
                 require_once 'classes/model/Groupwf.php';
                 require_once 'classes/model/Content.php';
                 $groups = array();
                 //SELECT
                 $criteria = new Criteria('workflow');
                 $criteria->setDistinct();
                 $criteria->addSelectColumn(GroupwfPeer::GRP_UID);
                 $criteria->addSelectColumn(ContentPeer::CON_VALUE);
                 //FROM
                 $conditions = array();
                 $conditions[] = array(GroupwfPeer::GRP_UID, ContentPeer::CON_ID);
                 $conditions[] = array(ContentPeer::CON_CATEGORY, DBAdapter::getStringDelimiter() . 'GRP_TITLE' . DBAdapter::getStringDelimiter());
                 $conditions[] = array(ContentPeer::CON_LANG, DBAdapter::getStringDelimiter() . 'en' . DBAdapter::getStringDelimiter());
                 $criteria->addJoinMC($conditions, Criteria::LEFT_JOIN);
                 //WHERE
                 $criteria->add(GroupwfPeer::GRP_STATUS, 'ACTIVE');
                 //ORDER BY
                 $criteria->addAscendingOrderByColumn(ContentPeer::CON_VALUE);
                 $dataset = GroupwfPeer::doSelectRS($criteria);
                 $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
                 $dataset->next();
                 while ($row = $dataset->getRow()) {
                     $groups[] = array('OWNER_UID' => $row['GRP_UID'], 'OWNER_NAME' => $row['CON_VALUE']);
                     $dataset->next();
                 }
                 $result->total = GroupwfPeer::doCount($criteria);
                 $result->owners = $groups;
                 break;
         }
     } catch (Exception $error) {
         $result->status = 'ERROR';
         $result->message = $error->getMessage();
     }
     return $result;
 }
Exemplo n.º 12
0
 public function getUsers($params)
 {
     require_once 'classes/model/Users.php';
     G::LoadClass('configuration');
     $conf = new Configurations();
     $search = isset($params['search']) ? $params['search'] : null;
     $users = Users::getAll($params['start'], $params['limit'], $search);
     foreach ($users->data as $i => $user) {
         $users->data[$i]['USER'] = $conf->getEnvSetting('format', array('userName' => $user['USR_USERNAME'], 'firstName' => $user['USR_FIRSTNAME'], 'lastName' => $user['USR_LASTNAME']));
     }
     print G::json_encode($users);
 }
 function setViewVariables($view_type, $user_filter, $status_filter)
 {
     //Get Users Info
     if (logged_user()->isMemberOfOwnerCompany()) {
         $users = Users::getAll();
     } else {
         $users = logged_user()->getCompany()->getUsers();
     }
     //Get Companies Info
     if (logged_user()->isMemberOfOwnerCompany()) {
         $companies = Companies::getCompaniesWithUsers();
     } else {
         $companies = array(logged_user()->getCompany());
     }
     $usr = Users::findById($user_filter);
     $user_filter_comp = $usr != null ? $usr->getCompanyId() : 0;
     tpl_assign('users', $users);
     tpl_assign('companies', $companies);
     tpl_assign('userPreferences', array('view_type' => $view_type, 'user_filter' => $user_filter, 'status_filter' => $status_filter, 'user_filter_comp' => $user_filter_comp));
 }
 /**
  * Send multiple emails using this simple tool
  *
  * @param void
  * @return null
  */
 function tool_mass_mailer()
 {
     $tool = AdministrationTools::getByName('mass_mailer');
     if (!$tool instanceof AdministrationTool) {
         flash_error(lang('administration tool dnx', 'test_mail_settings'));
         $this->redirectTo('administration', 'tools');
     }
     // if
     $massmailer_data = array_var($_POST, 'massmailer');
     tpl_assign('tool', $tool);
     tpl_assign('grouped_users', Users::getGroupedByCompany());
     tpl_assign('massmailer_data', $massmailer_data);
     if (is_array($massmailer_data)) {
         try {
             $subject = trim(array_var($massmailer_data, 'subject'));
             $message = trim(array_var($massmailer_data, 'message'));
             $errors = array();
             if ($subject == '') {
                 $errors[] = lang('massmailer subject required');
             }
             // if
             if ($message == '') {
                 $errors[] = lang('massmailer message required');
             }
             // if
             $users = Users::getAll();
             $recipients = array();
             if (is_array($users)) {
                 foreach ($users as $user) {
                     if (array_var($massmailer_data, 'user_' . $user->getId()) == 'checked') {
                         $recipients[] = Notifier::prepareEmailAddress($user->getEmail(), $user->getDisplayName());
                     }
                     // if
                 }
                 // foreach
             }
             // if
             if (!count($recipients)) {
                 $errors[] = lang('massmailer select recipients');
             }
             // if
             if (count($errors)) {
                 throw new FormSubmissionErrors($errors);
             }
             // if
             if (Notifier::sendEmail($recipients, Notifier::prepareEmailAddress(logged_user()->getEmail(), logged_user()->getDisplayName()), $subject, $message)) {
                 flash_success(lang('success massmail'));
             } else {
                 flash_error(lang('error massmail'));
             }
             // if
             $this->redirectToUrl($tool->getToolUrl());
         } catch (Exception $e) {
             tpl_assign('error', $e);
         }
         // try
     }
     // if
 }
Exemplo n.º 15
0
    }
    //print_r($_POST);
}
/***************************************************************************/
?>

<div class="form-group">
    <h2 class="naslov"> Unesite podatke o dugovanju.</h2>
    <br>
    <form action="" method="POST">
        <i class="fa fa-user"></i> <label for="user_id">Izaberite korisnika </label>
        <select class="form-control" name="user_id" id="user_id">
            <option value="-1">Izaberite korisnika:</option>
			<?php 
/************************************************************************/
$all_users = Users::getAll();
foreach ($all_users as $user) {
    echo "<option value='{$user->user_id}'>{$user->user_id}. {$user->user_name} {$user->user_surname}</option>";
}
/**************************************************************************/
?>
        </select>
        <br>
        <i class="fa fa-money"></i> <label for="how_much">Koliko:</label>
        <select class="form-control" id="how_much" name="how_much">
            <option value="-1">Izaberite koliko:</option>
            <?php 
/************************************************************************************************/
$all_prices = Prices::getAll();
foreach ($all_prices as $price) {
    echo "<option value='{$price->price_id}'>{$price->price_name} {$price->price} din </option>";
Exemplo n.º 16
0
<?php

require_javascript('og/modules/addMessageForm.js');
?>

<div class="og-add-subscribers">
<?php 
if (!isset($users) || !is_array($users)) {
    $users = Users::getAll();
}
if (!isset($groupUserIds) || !is_array($groupUserIds)) {
    $groupUserIds = array(logged_user()->getId());
}
if (!isset($genid)) {
    $genid = gen_id();
}
$grouped = array();
$allChecked = true;
foreach ($users as $user) {
    if (!in_array($user->getId(), $groupUserIds)) {
        $allChecked = false;
    }
    if (!isset($grouped[$user->getCompanyId()]) || !is_array($grouped[$user->getCompanyId()])) {
        $grouped[$user->getCompanyId()] = array();
    }
    // if
    $grouped[$user->getCompanyId()][] = $user;
}
// foreach
$companyUsers = $grouped;
?>
Exemplo n.º 17
0
 function getAssignableUsers($project = null)
 {
     if ($this->isMemberOfOwnerCompany()) {
         return Users::getAll();
     }
     TimeIt::start('get assignable users');
     if ($project instanceof Project) {
         $ws = $project->getAllSubWorkspacesQuery(true);
     }
     $users = $this->getCompany()->getUsers();
     $uid = $this->getId();
     $cid = $this->getCompany()->getId();
     $tp = TABLE_PREFIX;
     $gids = "SELECT `group_id` FROM `{$tp}group_users` WHERE `user_id` = {$uid}";
     $q1 = "SELECT `project_id` FROM `{$tp}project_users` WHERE (`user_id` = {$uid} OR `user_id` IN ({$gids})) AND `can_assign_to_other` = '1'";
     $q2 = "SELECT `project_id` FROM `{$tp}project_users` WHERE (`user_id` = {$uid} OR `user_id` IN ({$gids})) AND `can_assign_to_owners` = '1'";
     if (isset($ws)) {
         $q1 .= " AND `project_id` IN ({$ws})";
         $q2 .= " AND `project_id` IN ({$ws})";
     }
     $query1 = "SELECT `user_id` FROM `{$tp}project_users` WHERE `project_id` IN ({$q1})";
     $query2 = "SELECT `user_id` FROM `{$tp}project_users` WHERE `project_id` IN ({$q2})";
     // get users from other client companies that share workspaces in which the user can assign to other clients' members
     $us1 = Users::findAll(array('conditions' => "`id` IN ({$query1}) AND `company_id` <> 1 AND `company_id` <> {$cid}"));
     // get users from the owner company that share workspaces in which the user can assign to owner company members
     $us2 = Users::findAll(array('conditions' => "`id` IN ({$query2}) AND `company_id` = 1"));
     $users = array_merge($users, $us1);
     $users = array_merge($users, $us2);
     TimeIt::stop();
     return $users;
 }
Exemplo n.º 18
0
echo 'group[can_add_mail_accounts]';
?>
" class="checkbox"><?php 
echo lang('can add mail accounts');
?>
</label>
    </div>
  </fieldset>

   <fieldset class="">
	 <legend><?php 
echo lang('group users');
?>
</legend>
		<?php 
$allUsers = Users::getAll();
$groupUserIds = array();
foreach ($allUsers as $user) {
    if (array_var($group_data, 'user[' . $user->getId() . ']')) {
        $groupUserIds[] = $user->getId();
    }
}
tpl_assign('genid', $genid);
tpl_assign('$users', $allUsers);
tpl_assign('groupUserIds', $groupUserIds);
$this->includeTemplate(get_template_path('group_users_control', 'group'));
?>
   </fieldset>
  
   <fieldset class="">
	 <legend><?php 
Exemplo n.º 19
0
function user_select_box($list_name, $selected = null, $attributes = null)
{
    $logged_user = logged_user();
    $users = Users::getAll();
    if (is_array($users)) {
        foreach ($users as $user) {
            $option_attributes = $user->getId() == $selected ? array('selected' => 'selected') : null;
            $options[] = option_tag($user->getDisplayName(), $user->getId(), $option_attributes);
        }
        // foreach
    }
    // if
    return select_box($list_name, $options, $attributes);
}
Exemplo n.º 20
0
    <section class="events" id="events">
        <?php 
if (isset($_GET['users'])) {
    require_once "includes/Users.php";
    $users = new Users($core, $db, $user, $security);
    if (isset($_GET['edit'])) {
        if ($user['role'] == 2) {
            echo '<article class="text-box">';
            $users->edit($_GET['edit']);
            echo '</article>';
        } else {
            $core->notAllowed();
        }
    } else {
        if ($user['role'] == 2) {
            $users->getAll();
        } else {
            $core->notAllowed();
        }
    }
} elseif (isset($_GET['workshops'])) {
    require_once "includes/Workshops.php";
    $workshops = new Workshops($core, $db, $user);
    if (isset($_GET['add'])) {
        if ($user['role'] == 2) {
            echo '<article class="text-box">';
            $workshops->add($_GET['workshops']);
            echo '</article>';
        } else {
            $core->notAllowed();
        }
Exemplo n.º 21
0
<div class="back">
    <a href="../index.php"><img src="images/back-min.png"></a>
</div>
<div align="center">
    <img src="images/Users-icon.png">

    <div id="users">
        <h1><strong>Пользователи</strong></h1>
    </div>
    <table id="table" border="solid 1px">
        <tr>
            <td><h4>&nbsp&nbsp № &nbsp&nbsp</h4></td>
            <td><h4>&nbsp&nbsp Имя пользователя &nbsp&nbsp</h4></td>
        </tr>
        <?php 
foreach ($users->getAll() as $k => $v) {
    echo '<tr>';
    echo '<td>' . '<h4>' . ($k += 1) . '.</h4>' . '</td>';
    foreach ($v as $key => $value) {
        if ($key == 'login') {
            echo '<td>' . '<h4>' . $value . '</h4>' . '</td>';
            echo '</tr>';
        }
    }
}
?>
    </table>
</div>
</body>
</html>
Exemplo n.º 22
0
 /**
  * Get users list
  *
  * @param $params httpdata object
  */
 public function getUsers($params)
 {
     require_once 'classes/model/Users.php';
     $search = isset($params->search) ? $params->search : null;
     return Users::getAll($params->start, $params->limit, $search);
 }
Exemplo n.º 23
0
 /**
  * Send out the admin stats to any user that requests them
  */
 public static function stats()
 {
     if (is_array(self::$arrBandwidthData) && count(self::$arrBandwidthData) == 0) {
         self::$arrBandwidthData = array('last_bytes_in' => 0, 'last_bytes_out' => 0, 'peak_rate' => 0, 'previous_bandwidth_in' => array('unit' => 0, 'format' => '0B/s'), 'previous_bandwidth_out' => array('unit' => 0, 'format' => '0B/s'), 'last_monitor_request' => 0);
     }
     //Only output the monitor data once a secound
     if (self::$arrBandwidthData['last_monitor_request'] == 0 || time() - self::$arrBandwidthData['last_monitor_request'] >= 1) {
         //Reset the counter
         self::$arrBandwidthData['last_monitor_request'] = time();
         $intTotalUpTime = self::upTime();
         $arrServer = array();
         $arrUsers = Users::getAll();
         $arrConnections = Sockets::getAllConnected();
         $arrServer['uptime'] = array('unit' => $intTotalUpTime, 'format' => \Twist::DateTime()->getTimePeriod($intTotalUpTime));
         $arrServer['request_in'] = array('unit' => self::$intRequestsIn, 'format' => self::$intRequestsIn);
         $arrServer['request_out'] = array('unit' => self::$intRequestsOut, 'format' => self::$intRequestsOut);
         $arrServer['traffic_in'] = array('unit' => self::$intDataBytesIn, 'format' => \Twist::File()->bytesToSize(self::$intDataBytesIn));
         $arrServer['traffic_out'] = array('unit' => self::$intDataBytesOut, 'format' => \Twist::File()->bytesToSize(self::$intDataBytesOut));
         $arrServer['mem_usage'] = array('unit' => memory_get_usage(), 'format' => \Twist::File()->bytesToSize(memory_get_usage()));
         $arrServer['users'] = array('unit' => count($arrUsers), 'format' => count($arrUsers));
         $arrServer['connections'] = array('unit' => count($arrConnections), 'format' => count($arrConnections));
         //Calculate the avrage speed
         self::$intBandwidthTime = self::$intBandwidthTime == 0 ? self::$intUpTime : self::$intBandwidthTime;
         $intLastSpeedCheck = time() - self::$intBandwidthTime;
         if ($intLastSpeedCheck > 2) {
             $intBytesPerSecOut = floor((self::$intDataBytesOut - self::$arrBandwidthData['last_bytes_out']) / $intLastSpeedCheck);
             $arrServer['current_bandwidth_out'] = array('unit' => $intBytesPerSecOut, 'format' => sprintf('%s/s', \Twist::File()->bytesToSize($intBytesPerSecOut)));
             $intBytesPerSecIn = floor((self::$intDataBytesIn - self::$arrBandwidthData['last_bytes_in']) / $intLastSpeedCheck);
             $arrServer['current_bandwidth_in'] = array('unit' => $intBytesPerSecIn, 'format' => sprintf('%s/s', \Twist::File()->bytesToSize($intBytesPerSecIn)));
             //Now log and reset all the stats
             self::$arrBandwidthData['previous_bandwidth_in'] = $arrServer['current_bandwidth_in'];
             self::$arrBandwidthData['previous_bandwidth_out'] = $arrServer['current_bandwidth_out'];
             self::$arrBandwidthData['last_bytes_in'] = self::$intDataBytesIn;
             self::$arrBandwidthData['last_bytes_out'] = self::$intDataBytesOut;
             self::$intBandwidthTime = time();
         } else {
             $arrServer['current_bandwidth_in'] = self::$arrBandwidthData['previous_bandwidth_in'];
             $arrServer['current_bandwidth_out'] = self::$arrBandwidthData['previous_bandwidth_out'];
         }
         /**
         				if(array_key_exists('SocketChat',$this->resSocketModules)){
         
         					$intFixed = $intDynamic = 0;
         
         					foreach($this->resSocketModules['SocketChat']->arrChatRooms as $arrEachRoom){
         						($arrEachRoom['fixed']) ? $intFixed++ : $intDynamic++;
         					}
         
         					$arrServer['rooms'] = array('unit' => count($this->resSocketModules['SocketChat']->arrChatRooms),'format' => sprintf("%s (%d Fixed / %d Dynamic)",
         						count($this->resSocketModules['SocketChat']->arrChatRooms),
         						$intFixed,
         						$intDynamic
         					));
         				}*/
         $arrUserOut = array();
         foreach ($arrUsers as $arrEachUser) {
             $arrConnectionData = array();
             foreach ($arrConnections as $arrEachConnection) {
                 if ($arrEachConnection['data']['user_id'] == $arrEachUser['id']) {
                     $arrConnectionData[] = array('viewStatus' => array_key_exists('viewStatus', $arrEachConnection['data']) ? $arrEachConnection['data']['viewStatus'] : '', 'activeStatus' => array_key_exists('activeStatus', $arrEachConnection['data']) ? $arrEachConnection['data']['activeStatus'] : '', 'currentURI' => array_key_exists('currentURI', $arrEachConnection['data']) ? $arrEachConnection['data']['currentURI'] : '', 'ip' => $arrEachConnection['ip'], 'port' => $arrEachConnection['port']);
                 }
             }
             $arrUserOut[] = array('id' => $arrEachUser['id'], 'name' => $arrEachUser['name'], 'connections' => $arrConnectionData);
         }
         /**
         				$arrChatOut = array();
         
         				if(array_key_exists('SocketChat',$this->resSocketModules) && is_array($this->resSocketModules['SocketChat']->arrChatRooms)){
         
         					foreach($this->resSocketModules['SocketChat']->arrChatRooms as $arrEachRoom){
         
         						$strUserList = "";
         						foreach($arrEachRoom['users'] as $intUserID){
         							$arrUserData = $this->resUsers->getUser($intUserID);
         							$strUserList .= sprintf("%s, ",$arrUserData['name']);
         						}
         						$strUserList = rtrim(trim($strUserList),',')."\n";
         
         						$arrChatOut[] = array(
         							'gid' => $arrEachRoom['id'],
         							'name' => $arrEachRoom['name'],
         							'users' => $strUserList
         						);
         					}
         				}*/
         $arrResponseData = array('instance' => '', 'system' => 'twist', 'action' => 'debug', 'message' => 'System Stats', 'data' => array('server' => $arrServer, 'users' => $arrUserOut));
         Users::sendAdmin($arrResponseData, null, array('system_admin_log' => true));
     }
 }
Exemplo n.º 24
0
 public function listing()
 {
     $access_level = $this->session->userdata('user_indicator');
     $user_type = "1";
     $facilities = "";
     //If user is a super admin, allow him to add only facilty admin and nascop pharmacist
     if ($access_level == "system_administrator") {
         $user_type = "indicator='nascop_pharmacist' or indicator='facility_administrator'";
         $facilities = Facilities::getAll();
         $users = Users::getAll();
     } else {
         if ($access_level == "facility_administrator") {
             $facility_code = $this->session->userdata('facility');
             $user_type = "indicator='pharmacist'";
             $facilities = Facilities::getCurrentFacility($facility_code);
             $q = "u.Facility_Code='" . $facility_code . "' and Access_Level !='1' and Access_Level !='4'";
             $users = Users::getUsersFacility($q);
         }
     }
     $user_types = Access_Level::getAll($user_type);
     $tmpl = array('table_open' => '<table class=" table table-bordered table-striped setting_table ">');
     $this->table->set_template($tmpl);
     $this->table->set_heading('id', 'Name', 'Email Address', 'Phone Number', 'Access Level', 'Registered By', 'Options');
     foreach ($users as $user) {
         $links = "";
         $array_param = array('id' => $user['id'], 'role' => 'button', 'class' => 'edit_user', 'data-toggle' => 'modal');
         //Is user is a system admin, allow him to edit only system  admin and nascop users
         if ($access_level == "system_administrator") {
             if ($user['Access'] == "System Administrator" or $user['Access'] == "NASCOP Pharmacist" or $user['Access'] == "Facility Administrator") {
                 //$links = anchor('user_management/edit/' . $user['id'], 'Edit', array('class' => 'edit_user', 'id' => $user['id']));
                 //$links = anchor('#edit_user', 'Edit', $array_param);
                 //$links .= " | ";
             } else {
                 $links = "";
             }
         } else {
             //$links = anchor('user_management/edit/' . $user['id'], 'Edit', array('class' => 'edit_user', 'id' => $user['id']));
             //Only show edit link for pharmacists
             if ($user['Access'] == "Pharmacist" || $user['Access'] == "User") {
                 //$links = anchor('#edit_user', 'Edit', $array_param);
             }
         }
         if ($user['Active'] == 1) {
             if ($access_level == "system_administrator") {
                 //$links .= " | ";
                 $links .= anchor('user_management/disable/' . $user['id'], 'Disable', array('class' => 'disable_user'));
             } else {
                 if ($access_level == "facility_administrator" and $user['Access'] == "Pharmacist") {
                     //$links .= " | ";
                     $links .= anchor('user_management/disable/' . $user['id'], 'Disable', array('class' => 'disable_user'));
                 }
             }
         } else {
             //$links .= " | ";
             $links .= anchor('user_management/enable/' . $user['id'], 'Enable', array('class' => 'enable_user'));
         }
         if ($user['Access'] == "Pharmacist") {
             $level_access = "User";
         } else {
             $level_access = $user['Access'];
         }
         $this->table->add_row($user['id'], $user['Name'], $user['Email_Address'], $user['Phone_Number'], $level_access, $user['Creator'], $links);
     }
     $data['users'] = $this->table->generate();
     $data['user_types'] = $user_types;
     $data['facilities'] = $facilities;
     $data['order_sites'] = Sync_Facility::get_active();
     $data['title'] = "System Users";
     //$data['content_view'] = "users_v";
     $data['banner_text'] = "System Users";
     $data['link'] = "users";
     $actions = array(0 => array('Edit', 'edit'), 1 => array('Disable', 'disable'));
     $data['actions'] = $actions;
     $this->load->view("users_v", $data);
 }
Exemplo n.º 25
0
 function list_users()
 {
     $this->setTemplate(get_template_path("json"));
     ajx_current("empty");
     $usr_data = array();
     $users = Users::getAll();
     if ($users) {
         foreach ($users as $usr) {
             $usr_data[] = array("id" => $usr->getId(), "name" => $usr->getDisplayName());
         }
     }
     $extra = array();
     $extra['users'] = $usr_data;
     ajx_extra_data($extra);
 }