コード例 #1
0
ファイル: GroupMapper.php プロジェクト: hopitio/framework
 function updateGroup($pk, $data)
 {
     $update['groupCode'] = arrData($data, 'groupCode');
     $update['groupName'] = arrData($data, 'groupName');
     $update['stt'] = arrData($data, 'stt') ? 1 : 0;
     if (!$update['groupCode'] || !$update['groupName']) {
         return false;
     }
     $this->db->StartTrans();
     $pk = $this->replace($pk, $update);
     if (!$pk) {
         return false;
     }
     //user in group
     $this->db->delete('cores_group_user', 'groupFk=?', array($pk));
     foreach (arrData($data, 'users', array()) as $user) {
         $this->db->insert('cores_group_user', array('userFk' => $user, 'groupFk' => $pk));
     }
     //group permissions
     $this->db->delete('cores_group_permission', 'groupFk=?', array($pk));
     foreach (arrData($data, 'permissions', array()) as $pem) {
         $this->db->insert('cores_group_permission', array('groupFk' => $pk, 'permission' => $pem));
     }
     $this->db->CompleteTrans();
     return $pk;
 }
コード例 #2
0
ファイル: RestCtrl.php プロジェクト: hopitio/framework
 protected function restInput($key = null, $default = null)
 {
     $body = $this->req->getBody();
     if (!$body) {
         $body = file_get_contents('php://input');
     }
     $json = json_decode($body, true);
     return $key === null ? $json : arrData($json, $key, $default);
 }
コード例 #3
0
ファイル: Translator.php プロジェクト: hopitio/framework
 /**
  * 
  * @param type $key
  * @param type $params
  * @return str
  */
 function translate($key, $params = array())
 {
     $str = arrData($this->data, $key);
     if (!$str) {
         return '{{' . $key . '}}';
     }
     $ks = array_keys($params);
     $vs = array_values($params);
     foreach ($ks as &$k) {
         $k = '{{' . $k . '}}';
     }
     return str_replace($ks, $vs, $str);
 }
コード例 #4
0
ファイル: UserMapper.php プロジェクト: hopitio/framework
 function updateUser($id, $data)
 {
     $update['account'] = arrData($data, 'account');
     $update['fullName'] = arrData($data, 'fullName');
     $update['depFk'] = (int) arrData($data, 'depFk');
     $update['jobTitle'] = arrData($data, 'jobTitle');
     $update['stt'] = arrData($data, 'stt') ? 1 : 0;
     if (!$update['account'] || !$update['fullName']) {
         return;
     }
     if (!$id && !$data['newPass']) {
         return;
     }
     if (arrData($data, 'changePass') || !$id) {
         $update['pass'] = md5(arrData($data, 'newPass'));
     }
     $groups = arrData($data, 'groups', array());
     $permissions = arrData($data, 'permissions', array());
     $this->db->StartTrans();
     if ($id) {
         $this->db->update('cores_user', $update, 'pk=?', array($id));
     } else {
         $id = $this->db->insert('cores_user', $update);
     }
     //group
     $this->db->delete('cores_group_user', 'userFk=?', array($id));
     foreach ($groups as $groupFk) {
         $this->db->insert('cores_group_user', array('userFk' => $id, 'groupFk' => $groupFk));
     }
     //permissions
     $this->db->delete('cores_user_permission', 'userFk=?', array($id));
     foreach ($permissions as $pem) {
         $this->db->insert('cores_user_permission', array('userFk' => $id, 'permission' => $pem));
     }
     $this->db->CompleteTrans();
     return $id;
 }
コード例 #5
0
ファイル: Mapper.php プロジェクト: hopitio/framework
 function rebuildPath($parentCol, $pathCol, $srcCol, $fromNode = 0)
 {
     $this->db->startTrans();
     $table = $this->tableName();
     $node = $this->db->GetRow("SELECT * FROM {$table} WHERE pk=?", array($fromNode));
     $parentNode = $this->db->GetRow("SELECT * FROM {$table} WHERE pk=?", array(arrData($node, $parentCol)));
     $childNodes = $this->db->GetAll("SELECT * FROM {$table} WHERE {$parentCol}=?", array($fromNode));
     if (!empty($node)) {
         $path = arrData($parentNode, $pathCol, '/');
         $this->db->update($table, array($pathCol => $path . $node[$srcCol] . '/'), 'pk=?', array($node['pk']));
     }
     foreach ($childNodes as $node) {
         $this->rebuildPath($parentCol, $pathCol, $srcCol, $node['pk']);
     }
     $this->db->completeTrans();
 }
コード例 #6
0
ファイル: Setting.php プロジェクト: hopitio/framework
 function getSetting($key)
 {
     return arrData($this->settings, $key);
 }