function sess_write($key, $value) { // If the client doesn't have a session, and one isn't being created ($value), do nothing. if (empty($_COOKIE[session_name()]) && empty($value)) { return TRUE; } $Controller = getInstance()->Controller; $Session = new AppModel('Session'); $result = $Session->findById($key); $user_id = 0; if (isset($Controller->User->user['id'])) { $user_id = $Controller->User->user['id']; } if (isset($result['Session']['id'])) { $Session->save(array('hostname' => $_SERVER['REMOTE_ADDR'], 'session' => $value), array('id' => $key)); } else { $Session->create(array('id' => $key, 'hostname' => $_SERVER['REMOTE_ADDR'], 'session' => $value)); } return TRUE; }
/** * Get the parent node * * reads the parent id and returns this node * * @since 1.2 * @param AppModel $model * @param mixed $id The ID of the record to read * @param int $recursive The number of levels deep to fetch associated records * @return array Array of data for the parent node * @access public */ function get_parent_node(&$model, $id = null, $fields = null, $recursive = -1) { if (empty($id)) { $id = $model->id; } extract($this->settings[$model->name]); $parentId = $model->read($parent, $id); if ($parentId) { $parentId = $parentId[$model->name][$parent]; $parent = $model->findById($parentId, $fields, null, $recursive); return $parent; } else { return false; } }
/** * Inserts an item on a certain position * * @param AppModel $model * @param $position * @return boolean */ private function __insertAtPosition($model, $position) { extract($this->settings[$model->alias]); $data = $model->data; $model->data[$model->alias][$positionColumn] = 0; $model->save(null, array('validate' => $validate, 'callbacks' => $callbacks)); $model->create($data); $model->recursive = 0; $model->findById($model->id); $this->removeFromList($model); $result = $this->__incrementPositionsOnLowerItems($model, $position); if ($position <= $this->__bottomPositionInList($model) + 1) { $model->data[$model->alias][$positionColumn] = $position; $result = $model->save(null, array('validate' => $validate, 'callbacks' => $callbacks)); } return $result; }