示例#1
0
文件: Cast.php 项目: bjtenao/tudu-web
 /**
  * 获取构架配置可见的部门
  *
  * @param string $orgId
  * @param string $castId
  * @return boolean
  */
 public function getCastDepartments($orgId, $castId)
 {
     if (!$orgId || !$castId) {
         return new Oray_Dao_Recordset();
     }
     $table = 'v_cast_department';
     $columns = 'org_id AS orgid, dept_id AS deptid, dept_name AS deptname, parent_dept_id AS parentid, order_num as ordernum, moderators';
     $where = array();
     $where[] = 'org_id = ' . $this->_db->quote($orgId);
     $where[] = 'cast_id = ' . $this->_db->quote($castId);
     $where = implode(' AND ', $where);
     // ORDER
     $order = 'ORDER BY org_id, parent_dept_id, order_num DESC';
     $sql = "SELECT {$columns} FROM {$table} WHERE {$where} {$order}";
     $_records = $this->_db->fetchAll($sql);
     if (!$_records) {
         return new Oray_Dao_Recordset();
     }
     if (!class_exists('Dao_Md_Department_Department')) {
         require_once 'Dao/Md/Department/Department.php';
     }
     $records = array();
     $records = Dao_Md_Department_Department::sortRecords($_records);
     $records = Dao_Md_Department_Department::formatRecords($records);
     return new Oray_Dao_Recordset($records, 'Dao_Md_Department_Record_Department');
 }
示例#2
0
文件: Cast.php 项目: bjtenao/tudu-web
 /**
  * 获取用户可见的部门
  *
  * @param string $orgId
  * @param string $userId
  * @return boolean
  */
 public function getCastDepartments($orgId, $userId)
 {
     if (!$orgId || !$userId) {
         return new Oray_Dao_Recordset();
     }
     $orgId = $this->_db->quote($orgId);
     $userId = $this->_db->quote($userId);
     $table = 'md_department AS D ' . "LEFT JOIN md_cast_disable_dept AS UD ON UD.org_id = D.org_id AND UD.dept_id = D.dept_id AND UD.owner_id = {$userId}";
     $columns = 'D.org_id AS orgid, D.dept_id AS deptid, dept_name AS deptname, parent_dept_id AS parentid, ' . 'moderators, order_num as ordernum';
     $where = array();
     //$where[] = 'UD.org_id = ' . $this->_db->quote($orgId);
     //$where[] = 'UD.owner_id = ' . $this->_db->quote($userId);
     $where[] = "D.org_id = {$orgId}";
     $where[] = "UD.dept_id IS NULL";
     $where = implode(' AND ', $where);
     // ORDER
     $order = 'ORDER BY D.org_id, D.parent_dept_id, D.order_num DESC';
     $sql = "SELECT {$columns} FROM {$table} WHERE {$where} {$order}";
     $_records = $this->_db->fetchAll($sql);
     if (!$_records) {
         return new Oray_Dao_Recordset();
     }
     if (!class_exists('Dao_Md_Department_Department')) {
         require_once 'Dao/Md/Department/Department.php';
     }
     $records = array();
     $records = Dao_Md_Department_Department::sortRecords($_records);
     $records = Dao_Md_Department_Department::formatRecords($records);
     return new Oray_Dao_Recordset($records, 'Dao_Md_Department_Record_Department');
 }