예제 #1
0
 public function existsSetting($key)
 {
     $cond = new Moonlake_Model_Condition('AND');
     $cond->is('userid', $this->user->getId());
     $cond->is('key', $key);
     $data = $this->model->getEntriesByCondition($cond);
     return isset($data[0]);
 }
예제 #2
0
파일: auth.php 프로젝트: bmario/moonlake
 public function deleteAuthorizationForRole($context, Moonlake_Auth_Role $role, $action)
 {
     $cond = new Moonlake_Model_Condition();
     $cond->is('context', $context);
     $cond->is('role', $role->getId());
     $cond->is('action', $action);
     $this->model->deleteEntriesByCondition($cond);
 }
예제 #3
0
파일: roles.php 프로젝트: bmario/moonlake
 public function delete()
 {
     $mb = $this->model->getBackend();
     $auth = new Moonlake_Auth_AuthModel($mb);
     $cond = new Moonlake_Model_Condition();
     $cond->is('role', $this->roleid);
     $auth->deleteEntriesByCondition($cond);
     $roluser = new Moonlake_Auth_UsersRolesModel($mb);
     $roluser->deleteEntriesByCondition($cond);
     $this->model->deleteEntry($this->roleid);
 }
예제 #4
0
 /**
  * Update all entries which fit the conditions.
  * @param String area the area
  * @param Moonlake_Model_Condition $cond
  * @param String[] $fields an array with changes
  */
 public function updateEntriesByCondition($area, Moonlake_Model_Condition $cond, $fields)
 {
     $sql = 'UPDATE ' . $this->tableName($area) . ' SET ';
     $count = 0;
     foreach ($fields as $key => $val) {
         if ($count++ > 0) {
             $sql .= ', ';
         }
         $sql .= "`{$key}` = '{$val}'";
     }
     // add conditions to SQL
     if ($cond->hasConditions()) {
         $sql .= ' WHERE';
         $count = 0;
         foreach ($cond->getAllIs() as $field => $val) {
             $field = mysql_real_escape_string($field);
             $val = mysql_real_escape_string($val);
             if ($count > 0) {
                 $sql .= ' ' . $cond->getOperator();
             }
             $sql .= " `{$field}` = '{$val}'";
             $count++;
         }
         foreach ($cond->getAllLike() as $field => $val) {
             $field = mysql_real_escape_string($field);
             $val = mysql_real_escape_string($val);
             if ($count > 0) {
                 $sql .= ' ' . $cond->getOperator();
             }
             $sql .= " `{$field}` LIKE '%{$val}%'";
             $count++;
         }
         foreach ($cond->getAllLesser() as $field => $val) {
             $field = mysql_real_escape_string($field);
             $val = mysql_real_escape_string($val);
             if ($count > 0) {
                 $sql .= ' ' . $cond->getOperator();
             }
             $sql .= " `{$field}` < '{$val}'";
             $count++;
         }
         foreach ($cond->getAllGreater() as $field => $val) {
             $field = mysql_real_escape_string($field);
             $val = mysql_real_escape_string($val);
             if ($count > 0) {
                 $sql .= ' ' . $cond->getOperator();
             }
             $sql .= " `{$field}` > '{$val}'";
             $count++;
         }
     } else {
         // FIXME add an override for that, perhabs that could be useful?
         // uha, updating all? !! WTF?
         throw new Moonlake_Exception_ModelBackend("Your using an empty condition together with the request to update entries. Which does not seem to be a good idea.");
     }
     $this->con->free_query($this->con->query($sql));
 }
예제 #5
0
파일: users.php 프로젝트: bmario/moonlake
 public function deleteRole(Moonlake_Auth_Role $role)
 {
     $mb = $this->model->getBackend();
     $model = new Moonlake_Auth_UsersRolesModel($mb);
     $cond = new Moonlake_Model_Condition();
     $cond->is('user', $this->userid);
     $cond->is('role', $role->getId());
     $model->deleteEntriesByCondition($cond);
 }