示例#1
0
 /**
  * 获取考勤申请详细信息
  *
  * @param array $conditions
  * @param mixed $filter
  * @return Dao_Attend_Record_Apply
  */
 public function getApply(array $condition, $filter = null)
 {
     $table = 'attend_apply AS a LEFT JOIN attend_category AS c ON a.category_id = c.category_id';
     $columns = 'a.apply_id AS applyid, a.org_id AS orgid, a.tudu_id AS tuduid, a.category_id AS categoryid, a.unique_id AS uniqueid, a.period, ' . 'a.sender_id AS senderid, a.user_info AS userinfo, a.is_allday AS isallday, a.checkin_type AS checkintype, a.status, ' . 'a.start_time AS starttime, a.end_time AS endtime, a.create_time AS createtime, c.category_name as categoryname';
     $where = array();
     $bind = array();
     if (!empty($condition['applyid'])) {
         $where[] = 'a.apply_id = :applyid';
         $bind['applyid'] = $condition['applyid'];
     }
     if (!empty($condition['tuduid'])) {
         $where[] = 'a.tudu_id = :tuduid';
         $bind['tuduid'] = $condition['tuduid'];
     }
     if (empty($where)) {
         return null;
     }
     $where = implode(' AND ', $where);
     $sql = "SELECT {$columns} FROM {$table} WHERE {$where} LIMIT 1";
     try {
         $record = $this->_db->fetchRow($sql, $bind);
         if (!$record) {
             return null;
         }
         return Oray_Dao::record('Dao_App_Attend_Record_Apply', $record);
     } catch (Zend_Db_Exception $e) {
         $this->_catchException($e, __METHOD__);
         return null;
     }
 }
示例#2
0
文件: Rule.php 项目: bjtenao/tudu-web
 /**
  * 读取图度规则
  *
  * @param $condition
  * @param $filter
  */
 public function getRule(array $condition, $filter = null)
 {
     $table = 'td_rule';
     $columns = 'rule_id AS ruleid, unique_id AS uniqueid, description, operation, mail_remind AS mailremind, value, is_valid AS isvalid';
     $where = array();
     if (!empty($condition['ruleid'])) {
         $where[] = 'rule_id = ' . $this->_db->quote($condition['ruleid']);
     }
     if (!empty($condition['uniqueid'])) {
         $where[] = 'unique_id = ' . $this->_db->quote($condition['uniqueid']);
     }
     if (empty($where)) {
         return null;
     }
     if (isset($filter['isvalid'])) {
         $where[] = 'is_valid = ' . ($filter['isvalid'] ? 1 : 0);
     }
     $where = implode(' AND ', $where);
     $sql = "SELECT {$columns} FROM {$table} WHERE {$where} LIMIT 1";
     try {
         $record = $this->_db->fetchRow($sql);
         if (!$record) {
             return null;
         }
         return Oray_Dao::record('Dao_Td_Rule_Record_Rule', $record);
     } catch (Zend_Db_Exception $e) {
         $this->_catchException($e, __METHOD__);
         return null;
     }
 }
示例#3
0
 /**
  * 
  * @param array $condition
  * @param array $filter
  * @param mixed $sort
  * @param int   $maxCount
  * @return Oray_Dao_Recordset
  */
 public function getMeeting(array $condition, $filter = null, $sort = null, $maxCount = null)
 {
     $table = 'td_tudu_meeting';
     $columns = 'org_id AS orgid, tudu_id AS tuduid, notify_time AS notifytime, notify_type AS notifytype, location, ' . 'is_allday AS isallday';
     $where = array();
     $order = array();
     $limit = '';
     if (!empty($condition['tuduid'])) {
         $where[] = 'tudu_id = ' . $this->_db->quote($condition['tuduid']);
     }
     if (!$where) {
         return null;
     }
     // WHERE
     $where = implode(' AND ', $where);
     $sql = "SELECT {$columns} FROM {$table} WHERE {$where}";
     try {
         $record = $this->_db->fetchRow($sql);
         if (!$record) {
             return null;
         }
         return Oray_Dao::record('Dao_Td_Tudu_Record_Meeting', $record);
     } catch (Zend_Db_Exception $e) {
         $this->_catchException($e, __METHOD__);
         return null;
     }
 }
示例#4
0
 /**
  * 获取多条签到记录
  *
  * @param array $condition
  * @param array filter
  * @return Dao_App_Attend_Record_Checkin
  */
 public function getCheckin(array $condition, $filter = null)
 {
     $table = 'attend_checkin';
     $columns = 'checkin_id AS checkinid, org_id AS orgid, unique_id AS uniqueid, date, type, status, ip, ' . 'address, create_time AS createtime';
     $recordClass = 'Dao_App_Attend_Record_Checkin';
     $where = array();
     $bind = array();
     $where[] = 'org_id = :orgid';
     $bind['orgid'] = $condition['orgid'];
     $where[] = 'unique_id = :uniqueid';
     $bind['uniqueid'] = $condition['uniqueid'];
     $where[] = 'date = :date';
     $bind['date'] = $condition['date'];
     $where[] = 'type = :type';
     $bind['type'] = $condition['type'];
     $where = implode(' AND ', $where);
     if ($where) {
         $where = 'WHERE ' . $where;
     }
     $sql = "SELECT {$columns} FROM {$table} {$where} LIMIT 1";
     try {
         $record = $this->_db->fetchRow($sql, $bind);
         if (!$record) {
             return null;
         }
         return Oray_Dao::record($recordClass, $record);
     } catch (Zend_Db_Exception $e) {
         $this->_catchException($e, __METHOD__);
         return new Oray_Dao_Recordset();
     }
 }
示例#5
0
 /**
  * 获取一条模板记录
  * 
  * @param $condition
  * @param $filter
  * @return Dao_Td_Tudu_Template
  */
 public function getTemplate(array $condition, $filter = null)
 {
     $table = 'td_template';
     $columns = 'org_id AS orgid, board_id AS boardid, template_id AS templateid, creator, name, content, order_num AS ordernum';
     $where = array();
     if (isset($condition['orgid'])) {
         $where[] = 'org_id = ' . $this->_db->quote($condition['orgid']);
     }
     if (isset($condition['boardid'])) {
         $where[] = 'board_id = ' . $this->_db->quote($condition['boardid']);
     }
     if (isset($condition['templateid'])) {
         $where[] = 'template_id = ' . $this->_db->quote($condition['templateid']);
     }
     if (!$where) {
         return null;
     }
     // WHERE
     $where = implode(' AND ', $where);
     $sql = "SELECT {$columns} FROM {$table} WHERE {$where} LIMIT 1";
     try {
         $record = $this->_db->fetchRow($sql);
         if (!$record) {
             return null;
         }
         return Oray_Dao::record('Dao_Td_Tudu_Record_Template', $record);
     } catch (Zend_Db_Exception $e) {
         $this->_catchExecption($e, __METHOD__);
         return null;
     }
 }
示例#6
0
文件: File.php 项目: bjtenao/tudu-web
 /**
  * 获取文件记录
  *
  * @param $condition
  * @param $filter
  */
 public function getFile(array $condition, $filter = null)
 {
     $table = 'nd_file';
     $columns = 'org_id AS orgid, unique_id AS uniqueid, folder_id AS folderid, file_id AS fileid, is_from_attach as isfromattach, ' . 'attach_file_id AS attachfileid, file_name AS filename, size, path, type, is_share AS isshare, create_time AS createtime, ' . 'from_unique_id AS fromuniqueid, from_file_id AS fromfileid';
     $where = array();
     if (!empty($condition['uniqueid'])) {
         $where[] = 'unique_id = ' . $this->_db->quote($condition['uniqueid']);
     }
     if (!empty($condition['fileid'])) {
         $where[] = 'file_id = ' . $this->_db->quote($condition['fileid']);
     }
     if (empty($where)) {
         return null;
     }
     $where = implode(' AND ', $where);
     $sql = "SELECT {$columns} FROM {$table} WHERE {$where}";
     try {
         $record = $this->_db->fetchRow($sql);
         if (!$record) {
             return null;
         }
         return Oray_Dao::record('Dao_Td_Netdisk_Record_File', $record);
     } catch (Zend_Db_Exception $e) {
         $this->_catchException($e, __METHOD__);
         return null;
     }
 }
示例#7
0
文件: Post.php 项目: bjtenao/tudu-web
 /**
  * Get record
  *
  * SELECT org_id AS orgid, board_id AS boardid, unique_id AS uniqueid, tudu_id AS tuduid, post_id AS postid,
  * is_first AS isfirst, is_log AS islog, is_send AS issend, content, percnet, last_modify AS lastmodify,
  * poster, poster_info AS post_info, attach_num AS attachnum, elapsed_time AS elapsedtime, create_time AS createtime
  * WHERE tudu_id = ? AND post_id = ?
  *
  * @param array $condition
  * @param array $filter
  * @return Dao_Td_Tudu_Record_Post
  */
 public function getPost(array $condition, $filter = null)
 {
     $table = "td_post";
     $columns = "org_id AS orgid, board_id AS boardid, unique_id AS uniqueid, email, tudu_id AS tuduid, post_id AS postid, header, " . "is_first AS isfirst, is_log AS islog, is_send AS issend, content, percent, last_modify AS lastmodify, " . "poster, poster_info AS posterinfo, attach_num AS attachnum, elapsed_time AS elapsedtime, create_time AS createtime, " . "is_foreign AS isforeign";
     $where = array();
     if (isset($condition['tuduid'])) {
         $where[] = 'tudu_id = ' . $this->_db->quote($condition['tuduid']);
     }
     if (isset($condition['postid'])) {
         $where[] = 'post_id = ' . $this->_db->quote($condition['postid']);
     }
     if (isset($condition['uniqueid'])) {
         $where[] = 'unique_id = ' . $this->_db->quote($condition['uniqueid']);
     }
     if (isset($condition['issend'])) {
         $where[] = 'is_send = ' . $this->_db->quote($condition['issend']);
     }
     if (empty($where)) {
         return null;
     }
     // WHERE
     $where = implode(' AND ', $where);
     $sql = "SELECT {$columns} FROM {$table} WHERE {$where} LIMIT 0, 1";
     $record = $this->_db->fetchRow($sql);
     if (!$record) {
         return null;
     }
     return Oray_Dao::record('Dao_Td_Tudu_Record_Post', $record);
 }
示例#8
0
 /**
  * 获取指定单个联系人群组数据,返回联系人群组记录对象,若群组不存在则返回null
  * 
  * SELECT group_id AS groupid, unique_id AS uniqueid, is_system AS issystem, name, bgcolor
  * FROM td_contact_group WHERE group_id = ? AND unique_id = ?
  * 
  * @param array $condition
  * @param array $filter
  * @return Dao_Td_Contact_Group
  */
 public function getGroup(array $condition, $filter = null)
 {
     $table = 'td_contact_group';
     $columns = 'group_id AS groupid, unique_id AS uniqueid, is_system AS issystem, name AS groupname, bgcolor, order_num AS ordernum ';
     $where = array();
     if (!empty($condition['groupid'])) {
         $where[] = 'group_id = ' . $this->_db->quote($condition['groupid']);
     }
     if (!empty($condition['uniqueid'])) {
         $where[] = 'unique_id = ' . $this->_db->quote($condition['uniqueid']);
     }
     if (!$where) {
         return null;
     }
     if (isset($filter['issystem'])) {
         $where[] = 'is_system = ' . ($filter['issystem'] ? 1 : 0);
     }
     $where = implode(' AND ', $where);
     $sql = "SELECT {$columns} FROM {$table} WHERE {$where} LIMIT 1";
     try {
         $record = $this->_db->fetchRow($sql);
         if (!$record) {
             return null;
         }
         return Oray_Dao::record('Dao_Td_Contact_Record_Group', $record);
     } catch (Zend_Db_Exception $e) {
         $this->_catchException($e);
         return null;
     }
 }
示例#9
0
文件: Info.php 项目: bjtenao/tudu-web
 /**
  * 获取IP地址信息
  *
  * @param array $condition
  */
 public function getInfo(array $condition, $filter = null)
 {
     $table = 'md_ip_data';
     $columns = 'start_ip AS startip, end_ip AS endip, province, city';
     $where = array();
     if (isset($condition['ip'])) {
         if (!is_int($condition['ip'])) {
             $condition['ip'] = sprintf('%u', ip2long($condition['ip']));
         }
         $where[] = "end_ip >= {$condition['ip']} AND start_ip <= {$condition['ip']}";
     }
     if (empty($where)) {
         return null;
     }
     $where = implode(' AND ', $where);
     $sql = "SELECT {$columns} FROM {$table} WHERE {$where} LIMIT 1";
     try {
         $record = $this->_db->fetchRow($sql);
         if (!$record) {
             return null;
         }
         return Oray_Dao::record('Dao_Md_Ip_Record_Info', $record);
     } catch (Zend_Db_Exception $e) {
         $this->_catchException($e, __METHOD__);
         return null;
     }
 }
示例#10
0
文件: User.php 项目: bjtenao/tudu-web
 /**
  * 获取应用
  *
  * @param array $condition
  * @param unknown_type $filter
  */
 public function getAppUser(array $condition, $filter = null)
 {
     $table = 'app_user';
     $columns = 'org_id AS orgid, app_id AS appid, item_id AS itemid, role';
     $where = array();
     $bind = array();
     if (!empty($condition['orgid'])) {
         $where[] = 'org_id = :orgid';
         $bind['orgid'] = $condition['orgid'];
     }
     if (!empty($condition['appid'])) {
         $where[] = 'app_id = :appid';
         $bind['appid'] = $condition['appid'];
     }
     if (!empty($condition['itemid'])) {
         $where[] = 'item_id = :itemid';
         $bind['itemid'] = $condition['itemid'];
     }
     if (empty($where)) {
         return null;
     }
     $where = implode(' AND ', $where);
     $sql = "SELECT {$columns} FROM {$table} WHERE {$where} LIMIT 1";
     try {
         $record = $this->_db->fetchRow($sql);
         if (!$record) {
             return null;
         }
         return Oray_Dao::record($record, 'Dao_App_App_User');
     } catch (Zend_Db_Exception $e) {
         $this->_catchException($e, __METHOD__);
         return null;
     }
 }
示例#11
0
文件: Flow.php 项目: bjtenao/tudu-web
 /**
  *
  * @param array $condition
  * @param array $filter
  * @return Dao_Td_Record_Flow
  */
 public function getFlow(array $condition, $filter = null)
 {
     $table = 'td_tudu_flow';
     $columns = 'org_id as orgid, tudu_id as tuduid, flow_id as flowid, current_step_id as currentstepid, steps';
     $where = array();
     $bind = array();
     if (isset($condition['tuduid'])) {
         $where[] = 'tudu_id = :tuduid';
         $bind['tuduid'] = $condition['tuduid'];
     }
     if (empty($where)) {
         return null;
     }
     $where = implode(' AND ', $where);
     $sql = "SELECT {$columns} FROM {$table} WHERE {$where} LIMIT 1";
     try {
         $record = $this->_db->fetchRow($sql, $bind);
         if (!$record) {
             return null;
         }
         return Oray_Dao::record('Dao_Td_Tudu_Record_Flow', $record);
     } catch (Zend_Db_Exception $e) {
         $this->_catchException($e, __METHOD__);
         return null;
     }
 }
示例#12
0
 /**
  * 
  * @param array $condition
  * @param array $filter
  * @return Dao_Md_User_Record_Email
  */
 public function getEmail(array $condition, $filter = null)
 {
     $table = 'md_email';
     $columns = 'org_id AS orgid, user_id AS userid, address, password, protocol, imap_host AS host, port, ' . 'is_ssl AS isssl, type, last_check_info AS lastcheckinfo, last_check_time AS lastchecktime, ' . 'order_num AS ordernum';
     $where = array();
     if (!empty($condition['orgid'])) {
         $where[] = 'org_id = ' . $this->_db->quote($condition['orgid']);
     }
     if (!empty($condition['userid'])) {
         $where[] = 'user_id = ' . $this->_db->quote($condition['userid']);
     }
     if (!empty($condition['address'])) {
         $where[] = 'address = ' . $this->_db->quote($condition['address']);
     }
     if (!$where) {
         return null;
     }
     $where = implode(' AND ', $where);
     $sql = "SELECT {$columns} FROM {$table} WHERE {$where} LIMIT 1";
     try {
         $record = $this->_db->fetchRow($sql);
         if (!$record) {
             return null;
         }
         return Oray_Dao::record('Dao_Md_User_Record_Email', $record);
     } catch (Zend_Db_Exception $e) {
         $this->_catchException($e, __METHOD__);
         return null;
     }
 }
示例#13
0
文件: Flow.php 项目: bjtenao/tudu-web
 /**
  * SELECT
  * flow_id AS flowid, org_id AS orgid, board_id AS boardid, unique_id AS uniqueid, subject, description,
  * avaliable, is_valid AS isvalid, cc, elapsed_time AS elapsedtime, content, steps, create_time AS createtime
  * FROM td_flow
  * WHERE flow_id = :flowid AND unique_id = :uniqueid
  * LIMIT 0, 1
  *
  * @param array $condition
  * @param array $filter
  * @return boolean|NULL
  */
 public function getFlow(array $condition, $filter = null)
 {
     if (empty($condition['flowid'])) {
         return false;
     }
     $table = 'td_flow';
     $columns = 'flow_id AS flowid, org_id AS orgid, board_id AS boardid, unique_id AS uniqueid, subject, description, class_id as classid, ' . 'avaliable, is_valid AS isvalid, cc, elapsed_time AS elapsedtime, content, steps, create_time AS createtime';
     $where = array();
     $where[] = 'flow_id = ' . $this->_db->quote($condition['flowid']);
     if (isset($condition['uniqueid'])) {
         $where[] = 'unique_id = ' . $this->_db->quote($condition['uniqueid']);
     }
     if (!empty($filter) && array_key_exists('isvalid', $filter)) {
         if (null !== $filter['isvalid']) {
             $where[] = 'is_valid = ' . (int) $filter['isvalid'];
         }
     }
     $where = implode(' AND ', $where);
     if ($where) {
         $where = 'WHERE ' . $where;
     }
     $sql = "SELECT {$columns} FROM {$table} {$where} LIMIT 0, 1";
     $record = $this->_db->fetchRow($sql);
     if (!$record) {
         return null;
     }
     return Oray_Dao::record('Dao_Td_Flow_Record_Flow', $record);
 }
示例#14
0
文件: Date.php 项目: bjtenao/tudu-web
 /**
  * 获取签到日期的签到统计记录
  *
  * @param array $condition
  * @param array $filter
  * @return boolean|NULL|Dao_App_Attend_Record_Date
  */
 public function getAttendDate(array $condition, $filter = null)
 {
     if (empty($condition['uniqueid']) || empty($condition['date'])) {
         return false;
     }
     $table = 'attend_date d ' . 'LEFT JOIN attend_date_apply ad ON ad.org_id = d.org_id AND d.unique_id = ad.unique_id AND d.date = ad.date';
     $columns = 'd.org_id AS orgid, d.unique_id AS uniqueid, d.date, d.is_late AS islate, d.is_leave AS isleave, ' . 'd.is_work AS iswork, d.checkin_status AS checkinstatus, d.work_time AS worktime, d.update_time AS updatetime, ' . 'GROUP_CONCAT(DISTINCT(ad.memo)) AS memo, GROUP_CONCAT(DISTINCT(ad.category_id)) AS categories';
     $recordClass = 'Dao_App_Attend_Record_Date';
     $where = array();
     $bind = array('uniqueid' => $condition['uniqueid'], 'date' => $condition['date']);
     $where[] = 'd.unique_id = :uniqueid AND d.date = :date';
     if (isset($condition['orgid'])) {
         $where[] = 'd.org_id = :orgid';
         $bind['orgid'] = $condition['orgid'];
     }
     $where = 'WHERE ' . implode(' AND ', $where);
     $sql = "SELECT {$columns} FROM {$table} {$where} GROUP BY d.unique_id, d.date LIMIT 0, 1";
     try {
         $record = $this->_db->fetchRow($sql, $bind);
         if (!$record) {
             return null;
         }
         return Oray_Dao::record($recordClass, $record);
     } catch (Zend_Db_Exception $e) {
         $this->_catchException($e, __METHOD__);
         return null;
     }
 }
示例#15
0
 /**
  * 获取单个考勤分类的统计结果
  *
  * SELECT at.category_id AS categoryid, at.category_name AS categoryname, at.org_id AS orgid, 
  * at.unique_id AS uniqueid, at.date, at.total, at.update_time AS updatetime
  * FROM attend_total
  * WHERE category_id = :categoryid AND unique_id = uniqueid AND date = :date
  * LIMIT 0, 1
  *
  * @param array $condition
  * @return Dao_App_Attend_Record_Total|NULL|boolean
  */
 public function getAttendTotal(array $condition)
 {
     if (empty($condition['categoryid']) || empty($condition['uniqueid']) || empty($condition['date'])) {
         return false;
     }
     $table = 'attend_total at ' . 'LEFT JOIN attend_category ac ON at.org_id = ac.org_id AND at.category_id = ac.category_id';
     $columns = 'at.category_id AS categoryid, ac.category_name AS categoryname, at.org_id AS orgid, at.unique_id AS uniqueid, ' . 'at.date, at.total, at.update_time AS updatetime';
     $where = array();
     $recordClass = 'Dao_App_Attend_Record_Total';
     $bind = array('categoryid' => $condition['categoryid'], 'uniqueid' => $condition['uniqueid'], 'date' => $condition['date']);
     $where[] = 'at.category_id = :categoryid';
     $where[] = 'at.unique_id = :uniqueid';
     $where[] = 'at.date = :date';
     $where = 'WHERE ' . implode(' AND ', $where);
     $sql = "SELECT {$columns} FROM {$table} {$where} LIMIT 0, 1";
     try {
         $record = $this->_db->fetchRow($sql, $bind);
         if (!$record) {
             return null;
         }
         return Oray_Dao::record($recordClass, $record);
     } catch (Zend_Db_Exception $e) {
         $this->_catchException($e, __METHOD__);
         return null;
     }
 }
示例#16
0
 /**
  *
  * @param array $condition
  * @param array $filter
  * @return Oray_Dao_Recordset
  */
 public function getFolder(array $condition, $filter = null)
 {
     $table = 'nd_folder';
     $columns = 'org_id AS orgid, unique_id AS uniqueid, folder_id AS folderid, parent_folder_id AS parentfolderid, ' . 'folder_name AS foldername, max_quota AS maxquota, folder_size AS foldersize, create_time AS createtime, ' . 'is_system AS issystem, is_share AS isshare';
     $where = array();
     $order = array();
     $limit = '';
     if (!empty($condition['uniqueid'])) {
         $where[] = 'unique_id = ' . $this->_db->quote($condition['uniqueid']);
     }
     if (!empty($condition['orgid'])) {
         $where[] = 'org_id = ' . $this->_db->quote($condition['orgid']);
     }
     if (!empty($condition['folderid'])) {
         $where[] = 'folder_id = ' . $this->_db->quote($condition['folderid']);
     }
     if (!$where) {
         return null;
     }
     $where = implode(' AND ', $where);
     $sql = "SELECT {$columns} FROM {$table} WHERE {$where}";
     try {
         $record = $this->_db->fetchRow($sql);
         if (!$record) {
             return null;
         }
         return Oray_Dao::record('Dao_Td_Netdisk_Record_Folder', $record);
     } catch (Zend_Db_Exception $e) {
         $this->_catchException($e, __METHOD__);
         return fasle;
     }
 }
示例#17
0
文件: Real.php 项目: bjtenao/tudu-web
 /**
  * SELECT realname_id AS realnameid, org_id AS orgid, file_url AS fileurl, status, create_time AS createtime
  * FROM md_org_realname
  * WHERE realname_id = :realnameid
  * [AND org_id = :orgid]
  * LIMIT 0, 1
  *
  * @param array $condition
  * @param array $filter
  * @return Dao_Md_Org_Record_Real
  */
 public function getRealName(array $condition, $filter = null)
 {
     $table = 'md_org_realname';
     $columns = 'realname_id AS realnameid, org_id AS orgid, file_url AS fileurl, status, memo, create_time AS createtime, update_time AS updatetime';
     $recordClass = 'Dao_Md_Org_Record_Real';
     $where = array();
     if (!empty($condition['realnameid'])) {
         $where[] = 'realname_id = ' . $this->_db->quote($condition['realnameid']);
     }
     if (!empty($condition['orgid'])) {
         $where[] = 'org_id = ' . $this->_db->quote($condition['orgid']);
     }
     if (!$where) {
         return null;
     }
     if ($filter && !empty($filter['status'])) {
         $where[] = 'status = ' . (int) $filter['status'];
     }
     $where = implode(' AND ', $where);
     $sql = "SELECT {$columns} FROM {$table} WHERE {$where} ORDER BY create_time DESC LIMIT 1";
     $record = $this->_db->fetchRow($sql);
     if (!$record) {
         return null;
     }
     return Oray_Dao::record($recordClass, $record);
 }
示例#18
0
文件: Org.php 项目: bjtenao/tudu-web
 /**
  * 获取组织信息
  *
  * @param array $condition
  * @param array $filter
  * @return Dao_Md_Org_Record_Org
  */
 public function getOrg(array $condition, $filter = null)
 {
     $table = 'md_organization o ' . 'LEFT JOIN md_org_info oi ON o.org_id = oi.org_id ';
     $columns = 'o.org_id AS orgid, org_name AS orgname, oi.entire_name AS entirename, ts_id AS tsid, status, ' . 'create_time AS createtime, expire_date AS expiredate, ' . 'intro, skin, login_skin AS loginskin, is_active as isactive, ' . 'password_level AS passwordlevel, lock_time AS locktime, timezone, date_format AS dateformat, ' . 'is_ip_rule AS isiprule, o.default_password AS defaultpassword, o.is_https AS ishttps, o.time_limit AS timelimit';
     $where = array();
     $bind = array();
     if (!empty($condition['orgid'])) {
         $where[] = 'o.org_id = :orgid';
         $bind['orgid'] = $condition['orgid'];
     }
     if (!empty($condition['host'])) {
         $where[] = 'o.org_id = (SELECT org_id FROM md_org_host WHERE host = :host)';
         $bind['host'] = $condition['host'];
     }
     if (!$where) {
         return null;
     }
     $where = implode(' AND ', $where);
     $sql = "SELECT {$columns} FROM {$table} WHERE {$where} LIMIT 0, 1";
     try {
         $record = $this->_db->fetchRow($sql, $bind);
         if (!$record) {
             return null;
         }
         return Oray_Dao::record('Dao_Md_Org_Record_Org', $record);
     } catch (Zend_Db_Exception $e) {
         $this->_catchException($e, __METHOD__);
         return null;
     }
 }
示例#19
0
 /**
  *
  * @param $className
  * @param $dbKey
  */
 public static function getDao($className, $key)
 {
     $db = self::getDb($key);
     if (!isset(self::$_arrDao[$key][$className])) {
         self::$_arrDao[$key][$className] = Oray_Dao::factory($className, $db);
     }
     return self::$_arrDao[$key][$className];
 }
示例#20
0
 /**
  * 登录页面
  */
 public function indexAction()
 {
     $err = $this->_request->getQuery('err');
     $isValid = true;
     do {
         if (Zend_Session::isStarted()) {
             if ($this->_user->isAdminLogined()) {
                 return $this->referer($this->_basePath . '/');
             }
         }
         // 没有传入登录的SessionID
         if (empty($this->_sessionId)) {
             $isValid = false;
         }
         if (empty($this->_session->auth) || empty($this->_session->auth['address'])) {
             $isValid = false;
         }
     } while (false);
     if (!$isValid) {
         $url = $this->_request->getCookie('track');
         if (!$url) {
             $url = base64_decode($url);
         }
         if (!$url || !preg_match('/^https?:\\/\\//', $url)) {
             $url = $this->_options['sites']['tudu'];
         }
         return $this->referer($url . '/?error=admin');
     }
     if ($err && isset($this->_errMessages[$err])) {
         $err = $this->_errMessages[$err];
     }
     $memcache = $this->_bootstrap->memcache;
     $orgInfo = $memcache->get('TUDU-HOST-' . $this->_session->auth['orgid'] . '.tudu.com');
     if (!$orgInfo) {
         /* @var $daoOrg Dao_Md_Org_Org */
         $daoOrg = Oray_Dao::factory('Dao_Md_Org_Org', $this->_bootstrap->getResource('multidb')->getDefaultDb());
         $orgInfo = $daoOrg->getOrgByHost($this->_session->auth['orgid'] . '.tudu.com');
         $flag = null;
         $memcache->set('TUDU-HOST-' . $this->_session->auth['orgid'] . '.tudu.com', $orgInfo, $flag, 3600);
     }
     if ($orgInfo instanceof Dao_Md_Org_Record_Org) {
         $orgInfo = $orgInfo->toArray();
     }
     $this->view->options = array('sites' => $this->_options['sites']);
     $this->view->address = $this->_session->auth['userid'] . '@' . $this->_session->auth['orgid'];
     $this->view->err = $err;
     $this->view->org = $orgInfo;
     // 选择登陆模板
     if (!empty($orgInfo) && !empty($orgInfo['loginskin'])) {
         $loginSkin = $orgInfo['loginskin'];
         if (!empty($loginSkin['selected']) && !empty($loginSkin['selected']['value']) && $loginSkin['selected']['value'] != 'SYS:default') {
             $this->view->loginskin = $orgInfo['loginskin'];
             $this->render('custom');
         }
     }
 }
示例#21
0
文件: Role.php 项目: bjtenao/tudu-web
 /**
  * 获取群组数据
  *
  * @param array $condition
  * @param array $filter
  * @return Dao_Tudu_User_Record_Group
  */
 public function getRole(array $condition, $filter = null)
 {
     if (empty($condition['orgid']) || empty($condition['roleid'])) {
         return null;
     }
     $table = 'md_role';
     $columns = 'org_id AS orgid, role_id AS roleid, role_name AS rolename, is_system AS issystem, is_locked AS islocked, admin_level AS adminlevel';
     $where = array();
     $where[] = 'org_id = ' . $this->_db->quote($condition['orgid']);
     $where[] = 'role_id = ' . $this->_db->quote($condition['roleid']);
     $where = implode(' AND ', $where);
     $sql = "SELECT {$columns} FROM {$table} WHERE {$where} LIMIT 1";
     $record = $this->_db->fetchRow($sql);
     return Oray_Dao::record('Dao_Md_User_Record_Role', $record);
 }
示例#22
0
 /**
  * 聊天记录
  */
 public function logAction()
 {
     $jid = $this->_request->getQuery('jid');
     $email = $this->_request->getQuery('email');
     $clientKey = $this->_request->getQuery('clientkey');
     $page = max((int) $this->_request->getQuery('page'), 1);
     $pageSize = 100;
     $bootstrap = $this->getInvokeArg('bootstrap');
     $multidb = $bootstrap->getResource('multidb');
     $options = $bootstrap->getOptions();
     $config = $options['im'];
     $im = new Oray_Im_Client($config['host'], $config['port']);
     $userInfo = $im->getUserInfo($jid, $clientKey);
     if (!$userInfo) {
         //return $this->_redirect('/');
     }
     /* @var $daoChatLog Dao_Im_Chat_Log */
     $daoChatLog = Oray_Dao::factory('Dao_Im_Chat_Log', $multidb->getDb('im'));
     /* @var $daoUdContact Dao_Im_Contact_Contact */
     $daoUdContact = Oray_Dao::factory('Dao_Im_Contact_Contact', $multidb->getDb('im'));
     $jemail = explode('@', $jid);
     $userId = $jemail[0];
     $condition = array('orgid' => 'tudu', 'userid' => $userId, 'email' => $email);
     $info = $daoUdContact->getContact($condition);
     if (!$info) {
         $info = array('userid' => $userId, 'email' => $email, 'displayname' => $email);
     } else {
         $info = $info->toArray();
     }
     $logs = $daoChatLog->getLogPage(array('ownerid' => $jid, 'otherid' => $email), 'createtime DESC', $page, $pageSize);
     $this->view->pageinfo = array('currpage' => $logs->currentPage(), 'pagecount' => $logs->pageCount(), 'recordcount' => $logs->recordCount());
     $data = array('pageinfo' => array('currpage' => $logs->currentPage(), 'pagecount' => $logs->pageCount(), 'recordcount' => $logs->recordCount()));
     $logs = $logs->toArray();
     $ret = array();
     foreach ($logs as $log) {
         $ret[strtotime(date('Y-m-d', $log['createtime']))][$log['createtime']] = $log;
     }
     foreach ($ret as &$day) {
         ksort($day);
     }
     ksort($ret);
     $data['logs'] = $ret;
     $this->view->email = $email;
     $this->view->jid = $jid;
     $this->view->logs = $ret;
     $this->view->options = $options;
     $this->view->info = $info;
 }
示例#23
0
 /**
  * 获取指定排班方案数据
  *
  * @param array $condition
  * @param mixed $filter
  * @return Dao_App_Attend_Record_Schedule
  */
 public function getSchedule(array $condition, $filter = null)
 {
     $table = 'attend_schedule s ' . 'LEFT JOIN attend_schedule_rule r ON s.schedule_id = r.schedule_id AND s.org_id = r.org_id';
     $columns = 's.org_id AS orgid, s.unique_id AS uniqueid, s.schedule_id AS scheduleid, s.name, s.is_system AS issystem, r.rule_id AS ruleid, r.week, ' . 's.bgcolor, r.checkin_time AS checkintime, r.checkout_time AS checkouttime, ' . 'r.late_standard AS latestandard, r.late_checkin AS latecheckin, ' . 'r.leave_checkout AS leavecheckout, r.status, s.create_time AS createtime';
     $where = array();
     $bind = array();
     $recordClass = 'Dao_App_Attend_Record_Schedule';
     if (!empty($condition['orgid'])) {
         $where[] = 's.org_id = :orgid';
         $bind['orgid'] = $condition['orgid'];
     }
     if (!empty($condition['scheduleid'])) {
         $where[] = 's.schedule_id = :scheduleid';
         $bind['scheduleid'] = $condition['scheduleid'];
     }
     if (isset($condition['week'])) {
         $where[] = 'r.week = :week';
         $bind['week'] = $condition['week'];
     }
     if (isset($condition['status'])) {
         $where[] = 'r.status = :status';
         $bind['status'] = $condition['status'];
     }
     if (!empty($filter) && array_key_exists('isvalid', $filter)) {
         if (null !== $filter['isvalid']) {
             $where[] = 's.is_valid = ' . (int) $filter['isvalid'];
         }
     }
     if (empty($where)) {
         return null;
     }
     $where = implode(' AND ', $where);
     if ($where) {
         $where = 'WHERE ' . $where;
     }
     $sql = "SELECT {$columns} FROM {$table} {$where}";
     try {
         $record = $this->_db->fetchRow($sql, $bind);
         if (!$record) {
             return null;
         }
         return Oray_Dao::record($recordClass, $record);
     } catch (Zend_Db_Exception $e) {
         $this->_catchException($e, __METHOD__);
         return null;
     }
 }
示例#24
0
文件: App.php 项目: bjtenao/tudu-web
 /**
  *
  * @param array $condition
  * @param array $filter
  * @return Dao_Md_App_Record_App
  */
 public function getApp(array $condition, $filter = null)
 {
     if (empty($condition['orgid']) || empty($condition['appid'])) {
         return null;
     }
     $table = 'app_app a ' . 'LEFT JOIN app_info ai ON a.app_id = ai.app_id ' . 'LEFT JOIN app_user oa ON a.app_id = oa.app_id AND oa.org_id = ' . $this->_db->quote($condition['orgid']) . ' ';
     $columns = 'a.app_id AS appid, a.app_name AS appname, a.type, a.version, a.url, ai.author, ai.description, ai.logo, ai.languages, ' . 'ai.content, ai.score, ai.comment_num AS commentnum, ai.create_time AS createtime, ai.last_update_time AS lastupdatetime, ' . 'oa.status, oa.org_id AS orgid, oa.users, oa.expire_date AS expiredate';
     $where = array();
     $recordClass = 'Dao_Md_App_Record_App';
     $where[] = 'a.app_id = ' . $this->_db->quote($condition['appid']);
     $where = implode(' AND ', $where);
     $sql = "SELECT {$columns} FROM {$table} WHERE {$where}  LIMIT 0, 1";
     $record = $this->_db->fetchRow($sql);
     if (!$record) {
         return null;
     }
     return Oray_Dao::record($recordClass, $record);
 }
示例#25
0
文件: Info.php 项目: bjtenao/tudu-web
 /**
  * SELECT org_id AS orgid, industry, contact, tel, address, postcode, description
  * FROM md_org_info
  * WHERE org_id = :orgid
  *
  * @param array $condition
  * @param array $filter
  * @return Dao_Md_Org_Record_Info
  */
 public function getOrgInfo(array $condition, $filter = null)
 {
     $table = 'md_org_info';
     $columns = 'org_id AS orgid, entire_name AS entirename, industry, contact, tel, fax, province, city, address, postcode, description, realname_status AS realnamestatus ';
     $where = array();
     if (!empty($condition['orgid'])) {
         $where[] = 'org_id = ' . $this->_db->quote($condition['orgid']);
     }
     if (!$where) {
         return null;
     }
     $where = implode(' AND ', $where);
     $sql = "SELECT {$columns} FROM {$table} WHERE {$where} LIMIT 0, 1";
     $record = $this->_db->fetchRow($sql);
     if (!$record) {
         return null;
     }
     return Oray_Dao::record('Dao_Md_Org_Record_Info', $record);
 }
示例#26
0
文件: File.php 项目: bjtenao/tudu-web
 /**
  *
  *
  * @param $condition
  * @param $filter
  * @return Dao_Td_Attachment_Record_File
  */
 public function getFile(array $condition, $filter = null)
 {
     $table = "td_attachment a " . "LEFT JOIN td_attach_post ap ON a.file_id = ap.file_id";
     $columns = "a.file_id AS fileid, a.file_name AS filename, a.size, a.type, a.path, " . "ap.tudu_id AS tuduid, ap.post_id AS postid, a.unique_id as uniqueid, " . "a.create_time AS createtime";
     $where = array();
     if (isset($condition['fileid'])) {
         $where[] = 'a.file_id = ' . $this->_db->quote($condition['fileid']);
     }
     if (!$where) {
         return null;
     }
     $where = implode(' AND ', $where);
     $sql = "SELECT {$columns} FROM {$table} WHERE {$where} LIMIT 1";
     $record = $this->_db->fetchRow($sql);
     if (!$record) {
         return null;
     }
     return Oray_Dao::record('Dao_Td_Attachment_Record_File', $record);
 }
示例#27
0
 /**
  * 获取周期
  *
  * SELECT
  * cycle_id AS cycleid, mode, type, day, week, month, weeks,
  * at, what, period, count,
  * end_type AS endtype, end_count AS endcount, end_date AS enddate
  * FROM td_tudu_cycle
  * WHERE cycle_id = ?
  *
  * @param array $condition
  * @param array $filter
  * @return Dao_Td_Tudu_Record_Cycle
  */
 public function getCycle(array $condition, $filter = null)
 {
     $table = 'td_tudu_cycle';
     $columns = 'cycle_id AS cycleid, mode, type, day, week, month, weeks, ' . 'at, what, period, count, display_date AS displaydate, is_valid AS isvalid, is_keep_attach as iskeepattach, ' . 'end_type AS endtype, end_count AS endcount, end_date AS enddate';
     $where = array();
     if (!empty($condition['cycleid'])) {
         $where[] = 'cycle_id = ' . $this->_db->quote($condition['cycleid']);
     }
     if (!$where) {
         return null;
     }
     $where = implode(' AND ', $where);
     $sql = "SELECT {$columns} FROM {$table} WHERE {$where} LIMIT 1";
     $record = $this->_db->fetchRow($sql);
     if (!$record) {
         return null;
     }
     return Oray_Dao::record('Dao_Td_Tudu_Record_Cycle', $record);
 }
示例#28
0
 /**
  * Get record
  *
  * SQL here..
  *
  * @param array $condition
  * @param array $filter
  * @return Oray_Dao_Record
  */
 public function getAdminLog(array $condition, $filter = null)
 {
     $table = 'md_op_log';
     $columns = 'org_id AS orgid, user_id AS userid, module, action, sub_action AS subaction, ' . 'description, ip, local, create_time AS createtime';
     $where = array();
     if (empty($where)) {
         return null;
     }
     if (!empty($filter['orgid'])) {
         $where[] = 'org_id = ' . $this->_db->quote($filter['orgid']);
     }
     // WHERE
     $where = implode(' AND ', $where);
     $sql = "SELECT {$columns} FROM {$table} WHERE {$where} LIMIT 1";
     $record = $this->_db->fetchRow($sql);
     if (!$record) {
         return null;
     }
     return Oray_Dao::record('Dao_Md_Log_Record_Oplog', $record);
 }
示例#29
0
 /**
  * 获取用户配置信息
  *
  *
  * @param array $condition
  * @param array $filter
  * @return Dao_Md_User_Record_Option
  */
 public function getOption(array $condition, $filter = null)
 {
     $table = 'md_user_data';
     $columns = 'org_id AS orgid, user_id AS userid, skin, timezone, language, pagesize, settings, ' . 'date_format AS dateformat, profile_mode AS profilemode, expired_filter AS expiredfilter, ' . 'post_sort AS postsort, usual_local AS usuallocal';
     $where = array();
     if (!empty($condition['orgid']) && !empty($condition['userid'])) {
         $where[] = 'user_id = ' . $this->_db->quote($condition['userid']);
         $where[] = 'org_id = ' . $this->_db->quote($condition['orgid']);
     }
     if (!$where) {
         return null;
     }
     $where = implode(' AND ', $where);
     $sql = "SELECT {$columns} FROM {$table} WHERE {$where} LIMIT 0, 1";
     $record = $this->_db->fetchRow($sql);
     if (!$record) {
         return null;
     }
     return Oray_Dao::record('Dao_Md_User_Record_Option', $record);
 }
示例#30
0
 /**
  * Get record
  * 
  * SELECT product_id AS productid, product_name AS productname FROM md_product WHERE product_id = ?
  * 
  * @param array $condition
  * @param array $filter
  * @return Dao_Md_Product_Record_Product
  */
 public function getProduct(array $condition, $filter = null)
 {
     $table = 'md_product';
     $columns = 'product_id AS productid, product_name AS productname';
     $where = array();
     if (!empty($condition['productid'])) {
         $where[] = 'product_id = ' . $this->_db->quote($condition['productid']);
     }
     if (empty($where)) {
         return null;
     }
     // WHERE
     $where = implode(' AND ', $where);
     $sql = "SELECT {$columns} FROM {$table} WHERE {$where} LIMIT 1";
     $record = $this->_db->fetchRow($sql);
     if (!$record) {
         return null;
     }
     return Oray_Dao::record('Dao_Md_Product_Record_Product', $record);
 }