public function changeStatus(Model $Model, $status, $id = null, $force = false)
 {
     if ($id === null) {
         $id = $Model->getID();
     }
     if ($id === false) {
         return false;
     }
     $force = true;
     $Model->id = $id;
     if (!$Model->exists()) {
         throw new NotFoundException();
     }
     if ($force !== true) {
         $modelData = $Model->read();
         if ($modelData[$Model->alias]['status'] === $status) {
             CakeLog::write(LOG_WARNING, __d('webshop', 'The status of %1$s with id %2$d is already set to %3$s. Not making a change', strtolower(Inflector::humanize(Inflector::underscore($Model->name))), $id, $status), array('webshop'));
             return false;
         }
     } else {
         CakeLog::write(LOG_WARNING, __d('webshop', 'Status change of %1$s with id %2$d is being forced to %3$s', strtolower(Inflector::humanize(Inflector::underscore($Model->name))), $id, $status), array('webshop'));
     }
     $Model->saveField('status', $status);
     CakeLog::write(LOG_INFO, __d('webshop', 'Changed status of %1$s with id %2$d to %3$s', strtolower(Inflector::humanize(Inflector::underscore($Model->name))), $id, $status), array('webshop'));
     $eventData = array();
     $eventData[Inflector::underscore($Model->name)]['id'] = $id;
     $eventData[Inflector::underscore($Model->name)]['status'] = $status;
     $overallEvent = new CakeEvent($Model->name . '.statusChanged', $this, $eventData);
     $specificEvent = new CakeEvent($Model->name . '.statusChangedTo' . Inflector::camelize($status), $this, $eventData);
     CakeEventManager::instance()->dispatch($overallEvent);
     CakeEventManager::instance()->dispatch($specificEvent);
     return true;
 }
 public function createInvoice(Model $Model, $type = 'proforma', $id = null)
 {
     if ($id === null) {
         $id = $Model->getID();
     }
     if ($id === false) {
         return false;
     }
     $Model->id = $id;
     $Model->recursive = 2;
     $order = $Model->read();
     $invoice = array($this->Invoice->alias => array('type' => $type, 'status' => 'open', 'customer_id' => $order[$Model->alias]['customer_id']));
     foreach ($order['OrderProduct'] as $orderProduct) {
         $invoice[$this->Invoice->InvoiceProduct->alias][] = array('amount' => $orderProduct['amount'], 'price' => $orderProduct['price'], 'product_id' => $orderProduct['product_id'], 'tax_revision_id' => $orderProduct['tax_revision_id']);
     }
     foreach ($order['OrderShipment'] as $orderShipment) {
         $invoice[$this->Invoice->InvoiceShippingCost->alias][] = array('amount' => 15, 'shipment_id' => $orderShipment['shipment_id']);
     }
     foreach ($order['OrderPayment'] as $orderPayment) {
         $invoice[$this->Invoice->InvoiceTransactionCost->alias][] = array('amount' => 15, 'payment_id' => $orderPayment['payment_id']);
     }
     $status = $this->Invoice->saveAssociated($invoice, array('deep' => true));
     if (!$status) {
         return false;
     }
     return $this->Invoice->read();
 }
 public function testMultipleUploadSaveReadDelete()
 {
     // setup
     $this->Model->Behaviors->load('Media.Attachable', array());
     $this->Model->configureAttachment(array('files' => array('baseDir' => $this->attachmentDir, 'multiple' => true, 'removeOnOverwrite' => true)), true);
     $data = array($this->Model->alias => array('title' => 'My Upload', 'files_upload' => array($this->upload1, $this->upload2)));
     // save
     $this->Model->create();
     $result = $this->Model->save($data);
     $this->assertTrue(isset($this->Model->id));
     $this->assertEqual($result[$this->Model->alias]['files_upload'], '');
     $this->assertEqual(preg_match('/Upload_File_1_([0-9a-z]+).txt,Upload_File_2_([0-9a-z]+).txt$/', $result[$this->Model->alias]['files']), 1);
     $this->assertTrue(isset($result['Attachment']['files'][0]['path']));
     $this->assertTrue(file_exists($result['Attachment']['files'][0]['path']));
     $this->assertTrue(isset($result['Attachment']['files'][1]['path']));
     $this->assertTrue(file_exists($result['Attachment']['files'][1]['path']));
     // read
     $modelId = $this->Model->id;
     $this->Model->create();
     $result = $this->Model->read(null, $modelId);
     $this->assertTrue(isset($result[$this->Model->alias]['files']));
     $this->assertTrue(!isset($result[$this->Model->alias]['files_upload']));
     $this->assertEqual(preg_match('/Upload_File_1_([0-9a-z]+).txt,Upload_File_2_([0-9a-z]+).txt$/', $result[$this->Model->alias]['files']), 1);
     $this->assertTrue(isset($result['Attachment']['files'][0]['path']));
     $this->assertTrue(file_exists($result['Attachment']['files'][0]['path']));
     $this->assertTrue(isset($result['Attachment']['files'][1]['path']));
     $this->assertTrue(file_exists($result['Attachment']['files'][1]['path']));
     //delete
     $deleted = $this->Model->delete($this->Model->id);
     $this->assertTrue($deleted, 'Failed to delete Attachment');
     $this->assertTrue(!file_exists($result['Attachment']['files'][0]['path']), 'Attachment not deleted');
     $this->assertTrue(!file_exists($result['Attachment']['files'][1]['path']), 'Attachment not deleted');
 }
 public function beforeDelete(Model $model, $cascade = true)
 {
     $deletedData = $model->read([$this->getDuplicateKey($model), 'duplicate'], $model->id);
     if (!$deletedData[$model->alias]['duplicate']) {
         $this->setNewOriginal($model, $deletedData[$model->alias][$this->getDuplicateKey($model)]);
     }
     return true;
 }
Example #5
0
 /**
  * 获取用户信息
  */
 public function read($uid = null, $field = 'uid')
 {
     if (!$uid) {
         // 			if ($_SESSION['UID']) {
         // 				$uid = $_SESSION['UID'];
         // 			}
     }
     return parent::read($uid, 'uid');
 }
 /**
  * parentNode
  *
  * @param Model $model
  * @return array
  */
 public function parentNode($model)
 {
     if (!$model->id && empty($model->data)) {
         return null;
     }
     $data = $model->data;
     if (empty($model->data)) {
         $data = $model->read();
     }
     if (!isset($data['User']['role_id']) || !$data['User']['role_id']) {
         return null;
     } else {
         return array('Role' => array('id' => $data['User']['role_id']));
     }
 }
 /**
  * Before delete is called before any delete occurs on the attached model, but after the model's
  * beforeDelete is called. Returning false from a beforeDelete will abort the delete.
  *
  * @param Model $model Model using this behavior
  * @param bool $cascade If true records that depend on this record will also be deleted
  * @return mixed False if the operation should abort. Any other result will continue.
  */
 public function beforeDelete(Model $model, $cascade = true)
 {
     if (!empty($model->hasMany['Audit'])) {
         if ($model->id = !empty($model->id) ? $model->id : (!empty($model->data[$model->alias]['id']) ? $model->data[$model->alias]['id'] : '')) {
             $record = $model->read(null);
             $this->data[$model->id]['Audit']['entity'] = (!empty($model->plugin) ? $model->plugin . '.' : '') . $model->name;
             $this->data[$model->id]['Audit']['entity_id'] = $model->id;
             $this->data[$model->id]['Audit']['event'] = 'DELETE';
             $this->data[$model->id]['Audit']['old'] = json_encode($record[$model->alias]);
             $this->data[$model->id]['Audit']['new'] = json_encode(array());
             $this->data[$model->id]['Audit']['creator_id'] = !empty($model->data['Creator']['id']) ? $model->data['Creator']['id'] : null;
             $model->data = Hash::remove($model->data, 'Creator');
         }
     }
     return parent::beforeDelete($model, $cascade);
 }
Example #8
0
 /**
  * (non-PHPdoc)
  * @see Model::read()
  */
 public function read($val = null, $field = '', $fetchFields = '*')
 {
     $detail = parent::read($val, $field, $fetchFields);
     if (!$detail) {
         return array();
     }
     if ($this->saveContentType == 'txt') {
         $file = $this->getSaveFile($detail['id']);
         if (is_file($file)) {
             $detail['content'] = file_get_contents($file);
         } else {
             $detail['content'] = '';
         }
     } else {
         $mo = new Model($tbl_content);
         $detail['content'] = $mo->read($detail['id'], 'id', 'content');
     }
     return $detail;
 }
Example #9
0
 public static function getMealPlan($id)
 {
     $params = array("id" => $id);
     $returnArray = parent::read($params);
     return $returnArray[0];
 }
Example #10
0
 /**
  * 读取一条记录
  * @param string|int|float $val
  * @param string $field
  */
 public function read($val = null, $field = '', $fetchFields = '*')
 {
     if ($this->useCache) {
         $this->data = Cache::gets($val, $this->tbl);
         if ($this->data) {
             return $this->data;
         }
     }
     if ($field) {
         $this->data = Db::read($this->tbl, $val, $field, $fetchFields);
     } else {
         $this->data = Db::read($this->tbl, $val, $this->priKey, $fetchFields);
     }
     if ($this->useCache) {
         Cache::setProperties('outputSetKey', true);
         Cache::sets($val, $this->data, $this->tbl, null, null, $this->cacheExpire);
     }
     if ($this->saveContentType == 'txt') {
         $file = $this->getSaveFile($detail['id']);
         if (is_file($file)) {
             $detail['content'] = file_get_contents($file);
         } else {
             $detail['content'] = '';
         }
     } else {
         if ($this->saveContentType == 'db') {
             $mo = new Model($tbl_content);
             $detail['content'] = $mo->read($detail['id'], 'id', 'content');
         }
     }
     return !$this->data ? array() : $this->data;
 }
Example #11
0
 /**
  *  SetById method. Check is model innitialized.
  *
  *  If $id is defined read record from model with this primary key value
  *
  * @param Model $model
  * @param string $id  - value of model primary key to read
  * @param bool $checkId
  * @return boolean True if model initialized, false if no info in $model->data exists.
  */
 private function __setById(Model $model, $id = null, $checkId = true)
 {
     if (!isset($id)) {
         if ($checkId) {
             return isset($model->data[$model->alias][$model->primaryKey]);
         } else {
             return isset($model->data[$model->alias]);
         }
     } else {
         return $model->read(null, $id);
     }
 }
 /**
  * Updates the model's state when a $model->save() call is performed
  * 
  * @param	Model	$model		The model being acted on
  * @param	boolean $created	Whether or not the model was created
  * @param	array	$options	Options passed to save
  * @return	boolean
  */
 public function afterSave(Model $model, $created, $options = array())
 {
     if ($created) {
         $model->read();
         $model->saveField('state', $model->initialState);
     }
     return true;
 }
 public function afterSave(Model $model, $created, $options = array())
 {
     # broad check to make sure $model->data has all the fields
     # aggregation doesn't work if the foreignKey isn't in $model->data
     if (array_diff_key($model->schema(), $model->data[$model->alias]) !== array()) {
         $model->read();
     }
     foreach ($this->config[$model->alias] as $aggregate) {
         if (!array_key_exists($aggregate['model'], $model->belongsTo)) {
             continue;
         }
         $foreignKey = $model->belongsTo[$aggregate['model']]['foreignKey'];
         $foreignId = $model->data[$model->alias][$foreignKey];
         $this->__updateCache($model, $aggregate, $foreignKey, $foreignId);
         $oldForeignId = $this->foreignTableIDs[$aggregate['model']];
         if (!$created && $foreignId != $oldForeignId) {
             $this->__updateCache($model, $aggregate, $foreignKey, $oldForeignId);
         }
     }
 }
Example #14
0
 /**
  * @return array
  */
 public function readAll()
 {
     return $this->model->read($this->table);
 }
Example #15
0
     foreach ($data as $propname => $value) {
         $propname = ucfirst($propname);
         $setter = "set" . $propname;
         $obj->{$setter}($value);
     }
     $ret = $obj->save();
     $resp = array('msg' => 'sauvegardé', 'data' => $ret);
     header('Content-Type: application/json');
     header('Access-Control-Allow-Origin: *');
     header('Access-Control-Allow-Methods: GET, POST');
     echo json_encode($resp);
     break;
     //read
 //read
 case 'read':
     $obj = Model::read($class, $data->id);
     $obj = json_encode($obj);
     $resp = array('msg' => '', 'data' => $obj);
     header('Content-Type: application/json');
     header('Access-Control-Allow-Origin: *');
     header('Access-Control-Allow-Methods: GET, POST');
     echo json_encode($resp);
     break;
     //update
 //update
 case 'update':
     # code...
     break;
     //delete
 //delete
 case 'delete':
Example #16
0
 function retrieve($id)
 {
     parent::read($id);
     // post event
     Event::trigger('page:read', $this->rs);
 }
Example #17
0
 /**
  * Deletes all files associated with the record beforing delete it.
  *
  * @param object $model Reference to model
  * @return boolean Always true
  * @access public
  */
 function beforeDelete(Model $model, $cascade = true)
 {
     $model->read(null, $model->id);
     if (isset($model->data)) {
         foreach ($this->__fields[$model->alias] as $field => $options) {
             $this->_setFileToRemove($model, $field, $options['thumbnailDir']);
         }
     }
     return true;
 }
 /**
  * After saving load the full record from the database to 
  * return to the frontend
  *
  * @param object $model Model using this behavior
  * @param boolean $created True if this save created a new record
  */
 public function afterSave(Model $Model, $created)
 {
     // get all the data bancha needs for the response
     // and save it in the data property
     if ($created) {
         // just add the id
         $this->result = $Model->data;
         $this->result[$Model->name]['id'] = $Model->id;
     } else {
         // load the full record from the database
         $currentRecursive = $Model->recursive;
         $Model->recursive = -1;
         $this->result = $Model->read();
         $Model->recursive = $currentRecursive;
     }
     return true;
 }
Example #19
0
 /**
  * Automatically remove the uploaded file.
  */
 function beforeDelete(Model $Model, $cascade = true)
 {
     $Model->recursive = -1;
     $data = $Model->read();
     $this->Uploader[$Model->alias]->removeFile($data[$Model->alias][$this->options[$Model->alias]['fields']['name']]);
     return $Model->beforeDelete($cascade);
 }
 public function afterDelete(Model $model)
 {
     $allowed = true;
     if (empty($model->data)) {
         $model->data = $model->read();
     }
     if (!$this->settings[$model->alias]['calendarId']) {
         $allowed = false;
     }
     if (empty($model->data[$model->alias]['google_event_id'])) {
         $allowed = false;
     }
     if ($allowed) {
         $Events = ClassRegistry::init('Google.GoogleCalendarEvents');
         $calendarId = $this->settings[$model->alias]['calendarId'];
         $eventId = $model->data[$model->alias]['google_event_id'];
         $Events->delete($calendarId, $eventId);
     }
 }
Example #21
0
 /**
  * Deletes any files that have been attached to this model.
  *
  * @access public
  * @param Model $model
  * @param boolean $cascade
  * @return boolean
  */
 public function beforeDelete($model, $cascade = true)
 {
     if (empty($model->id)) {
         return false;
     }
     $data = $model->read(null, $model->id);
     $columns = $this->_columns[$model->alias];
     if (!empty($data[$model->alias])) {
         foreach ($data[$model->alias] as $column => $value) {
             if (isset($columns[$column])) {
                 $attachment = $this->_attachments[$model->alias][$columns[$column]];
                 $this->uploader->setup($attachment);
                 $this->s3 = $this->s3($attachment['s3']);
                 $this->delete($value);
             }
         }
     }
     return true;
 }
 public function beforeDelete(Model $model, $cascade = true)
 {
     $model->read(null, $model->id);
     $this->_deleteAttachments($model, $model->data[$model->name]['filename']);
     return true;
 }
Example #23
0
 /**
  * Returns true if the specified item is the last item
  *
  * @param Model $Model
  * @param Int $id
  * @return Boolean, true if it is the last item, false if not
  */
 public function isLast(Model $Model, $id = null)
 {
     if (!$id) {
         if ($Model->id) {
             $id = $Model->id;
         } elseif (!empty($Model->data) && isset($Model->data[$Model->alias][$Model->primaryKey])) {
             $id = $Model->id = $Model->data[$Model->alias][$Model->primaryKey];
         } else {
             return false;
         }
     } else {
         $Model->id = $id;
     }
     $Model->read();
     $last = $this->_highest($Model);
     return $last[$Model->alias][$Model->primaryKey] == $id;
 }
Example #24
0
 /**
  * Deletes any files that have been attached to this model.
  *
  * @access public
  * @param Model $model
  * @param boolean $cascade
  * @return mixed
  */
 public function beforeDelete(Model $model, $cascade = true)
 {
     if (empty($model->id)) {
         return false;
     }
     $data = $model->read(null, $model->id);
     $columns = $this->_columns[$model->alias];
     if (!empty($data[$model->alias])) {
         foreach ($data[$model->alias] as $column => $value) {
             if (isset($columns[$column])) {
                 $attachment = $this->_attachments[$model->alias][$columns[$column]];
                 $this->uploader->setup($attachment);
                 $this->s3 = $this->s3($attachment['s3']);
                 $path = $attachment['saveAsFilename'] ? rtrim($attachment['uploadDir'], '/') . '/' . $value : $value;
                 $this->delete($path);
             }
         }
     }
     return true;
 }
Example #25
0
 public function configuracoesHelpers($externo = 0)
 {
     if ($externo) {
     } else {
         $conexao = new Model();
         $conexao->setTabela('configuracoes');
         $ret = $conexao->read();
         $confDados = $ret[0];
         $this->_dominio = URL;
         if ($confDados) {
             $this->_marca_padrao = $confDados->marca_padrao;
             $this->_caminho_zero = $confDados->caminho_zero;
             $this->_caminho_forms = $confDados->caminho_forms;
             $this->_caminho_fotos = $confDados->caminho_fotos;
             $this->_emails_form_padrao = $confDados->email_forms;
             $this->_email_copia = $confDados->email_copia;
             $this->_link_resultado = $confDados->link_resultado;
             $this->_link_imprimir = $confDados->link_imprimir;
             $this->_link_compartilhar = $confDados->link_compartilhar;
             $this->_link_enviar = $confDados->link_enviar;
             $this->_link_proposta = $confDados->link_proposta;
             $this->_estoque_link_proposta = $confDados->estoque_link_proposta != '' ? $confDados->estoque_link_proposta : $confDados->link_proposta;
             $this->_estoque_link_verdetalhes = $confDados->estoque_link_verdetalhes;
             $this->_detalhes_link_proposta = $confDados->detalhes_link_proposta != '' ? $confDados->detalhes_link_proposta : $confDados->link_proposta;
             $this->_detalhes_link_financie = $confDados->detalhes_link_financie;
             $this->_detalhes_link_troca = $confDados->detalhes_link_troca;
             $this->_detalhes_prox_ant = $confDados->detalhes_prox_ant;
             $this->_detalhes_similares = $confDados->detalhes_similares;
             $this->_detalhes_mapa = $confDados->detalhes_mapa;
             $this->_compare_link_proposta = $confDados->comparativo_link_proposta != '' ? $confDados->comparativo_link_proposta : $confDados->link_proposta;
         }
     }
 }
 /**
  * Recursively traverses a presenter's up line to find the active sponsor
  * Takes into account isInactive 1-3 month
  *
  * @param Model $Model
  * @param int $presenter_id
  * @return int
  */
 private function findActiveSponsor(Model $Model, $presenter_id)
 {
     $Model->id = $presenter_id;
     $presenter = $Model->read();
     $Model->id = $presenter['Presenter']['sponsor_id'];
     $sponsor = $Model->read();
     if ($this->isInactive($sponsor['Presenter'])) {
         return $this->findActiveSponsor($Model, $sponsor['Presenter']['id']);
     } else {
         return $sponsor['Presenter']['id'];
     }
 }
Example #27
0
 /**
  * Before delete method. Called before all deletes
  *
  * Will delete the current node and all children using the deleteAll method and sync the table
  *
  * @param Model $Model Model instance
  * @param boolean $cascade
  * @return boolean true to continue, false to abort the delete
  */
 public function beforeDelete($Model, $cascade = true)
 {
     extract($this->settings[$Model->alias]);
     list($name, $data) = array($Model->alias, $Model->read());
     $data = $data[$name];
     if (!$data[$right] || !$data[$left]) {
         return true;
     }
     $diff = $data[$right] - $data[$left] + 1;
     if ($diff > 2) {
         if (is_string($scope)) {
             $scope = array($scope);
         }
         $scope[]["{$Model->alias}.{$left} BETWEEN ? AND ?"] = array($data[$left] + 1, $data[$right] - 1);
         $Model->deleteAll($scope);
     }
     $this->_sync($Model, $diff, '-', '> ' . $data[$right]);
     return true;
 }
Example #28
0
 /**
  * Does the actual saving of the Log model. Also adds the special field if possible.
  *
  * If model field in table, add the Model->alias
  * If action field is NOT in table, remove it from dataset
  * If the userKey field in table, add it to dataset
  * If userData is supplied to model, add it to the title
  *
  * @param Object $Model
  * @param array $logData
  */
 public function _saveLog(Model $Model, $logData, $title = null)
 {
     if ($title !== null) {
         $logData['Log']['title'] = $title;
     } elseif ($Model->displayField == $Model->primaryKey) {
         $logData['Log']['title'] = $Model->alias . ' (' . $Model->id . ')';
     } elseif (isset($Model->data[$Model->alias][$Model->displayField])) {
         $logData['Log']['title'] = $Model->data[$Model->alias][$Model->displayField];
     } else {
         $Model->recursive = -1;
         $Model->read(array($Model->displayField));
         $logData['Log']['title'] = $Model->data[$Model->alias][$Model->displayField];
     }
     if ($this->Log->hasField($this->settings[$Model->alias]['classField'])) {
         // by miha nahtigal
         $logData['Log'][$this->settings[$Model->alias]['classField']] = $Model->name;
     }
     if ($this->Log->hasField($this->settings[$Model->alias]['foreignKey']) && !isset($logData['Log'][$this->settings[$Model->alias]['foreignKey']])) {
         if ($Model->id) {
             $logData['Log'][$this->settings[$Model->alias]['foreignKey']] = $Model->id;
         } elseif ($Model->insertId) {
             $logData['Log'][$this->settings[$Model->alias]['foreignKey']] = $Model->insertId;
         }
     }
     if (!$this->Log->hasField('action')) {
         unset($logData['Log']['action']);
     } elseif (isset($Model->logableAction) && !empty($Model->logableAction)) {
         $logData['Log']['action'] = implode(',', $Model->logableAction);
         // . ' ' . $logData['Log']['action'];
         unset($Model->logableAction);
     }
     if ($this->Log->hasField('version_id') && isset($Model->version_id)) {
         $logData['Log']['version_id'] = $Model->version_id;
         unset($Model->version_id);
     }
     if ($this->Log->hasField('ip') && $this->userIP) {
         $logData['Log']['ip'] = $this->userIP;
     }
     if ($this->Log->hasField($this->settings[$Model->alias]['userKey']) && $this->user && isset($this->user[$this->UserModel->alias])) {
         $logData['Log'][$this->settings[$Model->alias]['userKey']] = $this->user[$this->UserModel->alias][$this->UserModel->primaryKey];
     }
     if ($this->Log->hasField('description')) {
         if (empty($logData['Log']['description'])) {
             $logData['Log']['description'] = __('Custom action');
         }
         if ($this->user && $this->UserModel && isset($this->user[$this->UserModel->alias])) {
             $logData['Log']['description'] .= ' ' . __('by') . ' ' . $this->settings[$Model->alias]['userModel'] . ' "' . $this->user[$this->UserModel->alias][$this->UserModel->displayField] . '"';
             if ($this->settings[$Model->alias]['description_ids']) {
                 $logData['Log']['description'] .= ' (' . $this->user[$this->UserModel->alias][$this->UserModel->primaryKey] . ')';
             }
         } else {
             // UserModel is active, but the data hasnt been set. Assume system action.
             $logData['Log']['description'] .= __(' by System');
         }
         $logData['Log']['description'] .= '.';
     }
     $this->Log->create($logData);
     $this->Log->save(null, false);
 }
 /**
  * beforeDelete callback
  * 
  * Used to retreive each ContentStream and store on the runtime variable.
  * 
  * @access public
  * @param Model $Model
  * @param boolean $cascade
  * @return true Always true, so de deleting proccess can be continued
  */
 function beforeDelete(&$Model, $cascade)
 {
     $this->runtime[$Model->alias]['delete'] = array();
     $data = $Model->data;
     foreach ($this->settings[$Model->alias]['streams'] as $fk => $stream) {
         if (empty($data[$Model->alias][$fk])) {
             $data = $Model->read();
         }
         $this->runtime[$Model->alias]['delete'][$stream['assocName']] = $data[$Model->alias][$fk];
     }
     return true;
 }
Example #30
0
 /**
  * Returns true if the specified item is the first item 
  *
  * @param Model $Model
  * @param Int $id
  * @return Boolean, true if it is the first item, false if not
  */
 public function isfirst(&$Model, $id = null)
 {
     if (!$id) {
         if ($Model->id) {
             $id = $Model->id;
         } elseif (!empty($Model->data) && isset($Model->data[$Model->alias][$Model->primaryKey])) {
             $id = $Model->id = $Model->data[$Model->alias][$Model->primaryKey];
         } else {
             return false;
         }
     } else {
         $Model->id = $id;
     }
     $Model->read();
     if ($Model->data[$Model->alias][$this->settings[$Model->alias]['field']] == 1) {
         return true;
     } else {
         return false;
     }
 }