/** * Returns admin note object * * @param array data * @param RM_Account_iUser obWriter * @return RM_AdminNote_Object */ public function createNote($data = array(), RM_Account_iUser $obWriter) { if (!@$data['type'] && !@$data['type_no_action'] && !@$data['body']) { $res = new RM_Base_Result(); $res->error('at_least_one_field'); throw new RM_Validator_Exception($res); } if (isNull($obUser = M('User')->loadUserById(@$data['user_id']))) { $res = new RM_Base_Result(); $res->error('no_such_user'); throw new RM_Validator_Exception($res); } $arr = array(); $arr['writer_id'] = $obWriter->id(); $arr['user_id'] = $obUser->id(); if (@$data['type']) { $arr['type'] = (int) $data['type']; } if (@$data['type_no_action']) { $arr['type_no_action'] = (int) $data['type_no_action']; } if (@$data['body']) { $arr['body'] = $data['body']; } //$arr['is_done'] = 1; $arr['posted'] = M('Tools')->date()->dbDateTime(); return $this->_mapper->_storage('adminNote')->createObject($arr); }
/** * Log report view by user * * @param RM_List_Object * @param RM_Account_iUser * @return void */ public function logView(RM_List_Object $list, RM_Account_iUser $user) { M('Db')->query('INSERT INTO ' . $this->_tables['log'] . ' (list_id, user_id, views, day) VALUES (?, ?, 1, DATE(NOW())) ON DUPLICATE KEY UPDATE views = views + 1', $list->id(), $user->id()); }
/** * Retrievs a list of purchases by barcode * * @param RM_Account_iUser $obUser * @return RM_Store_iRequest<RM_Store_Object> **/ public function getPurchasesByUser(RM_Account_iUser $obUser) { return $this->_storages['purchase']->getObjectList()->filter('user_id = ? AND status_id = 3 AND is_deleted = 0', $obUser->id()); }
/** * Get branch. * * @return list<hash> */ public function getBranch(RM_Account_iUser $obUser, $menuId = '') { if (!isset($this->_branches[$obUser->id()][$menuId])) { $menuData = $this->getMenuData($obUser); if (!isset($menuData['index'][$menuId]) || !isset($menuData['tree'])) { return array(); } foreach ($menuData['index'][$menuId] as $level => $idx) { $arr = !@$arr ? $menuData['tree'][$idx] : $arr['nested'][$idx]; //$result[] = $arr['item']; $result[] = $arr; } $this->_branches[$obUser->id()][$menuId] = $result; } return $this->_branches[$obUser->id()][$menuId]; }
/** * Returns family (list of persons) * * @param RM_Account_iUser obUser user object * @return RM_Store_iRequest <RM_Family_Object> **/ public function getFamily(RM_Account_iUser $obUser) { return $this->_storage['person']->getObjectList()->filter('user_id = ? AND is_deleted = 0', $obUser->id())->sort('is_panelist', 'DESC')->sort('is_animal', 'ASC')->sort('birthday', 'ASC'); }
/** * Creates (not save) forum entity object * * @param string entity_name * @param array data * @param RM_Account_iUser obUser * @return RM_Forum_Entity(Theme|Topic|Comment) **/ public function createEntity($entity_name, $data = array(), RM_Account_iUser $obUser) { if (!isNull($obParent = M('Forum')->loadById($data['parent_id']))) { $obParent->access('COMMENT'); } $data['type'] = $entity_name; $data['owner_id'] = $obUser->id(); return $this->_entity->createObject($data); }
/** * @see RM_Ticket_Facade::markAsReadList */ public function markAsReadList(RM_Account_iUser $obUser, $arr) { $this->_dbh->exec("DELETE FROM " . $this->_tables['new'] . " WHERE user_id = ? AND ticket_id IN(" . implode(',', $arr) . ")", $obUser->id()); }
/** * Checks does user have access for this report? * * @return bool **/ public function checkAccess(RM_Account_iUser $obUser) { if (!$obUser->id()) { return FALSE; } if (!isset(self::$_user_list_access[$obUser->id()])) { $list = $this->_mapper->availableReports(); foreach ($list as $l) { self::$_user_list_access[$obUser->id()][$l->id()] = TRUE; //echo $obUser->id() . ' hav access => ' . $l->id() . '<br>'; } } return (bool) isset(self::$_user_list_access[$obUser->id()][$this->id()]); }
public function canLoadToExcelPanelist(RM_Account_iUser $obUser) { if ($obUser->isUserInGroup(array('super-admin', 'support-control', 'support-payment'))) { return TRUE; } return FALSE; }