/** * Overrides delete() in App_Model. * * When a group is deleted, all its children are linked * to its parent * * @param mixed $where * @access public * @return int */ public function delete($where) { if (is_numeric($where)) { $where = $this->_primary . ' = ' . $where; } $select = new Zend_Db_Select($this->_db); $select->from($this->_name); $select->where($where); $rows = $this->_db->fetchAll($select); $userGroupModel = new BackofficeUserGroup(); foreach ($rows as $row) { $children = $this->findByParentId($row['id']); foreach ($children as $child) { $this->update(array('parent_id' => $row['parent_id']), $this->_db->quoteInto('id = ?', $child['id'])); $userGroupModel->routeUsersToGroup($row['id'], $row['parent_id']); } } return parent::delete($where); }
/** * Delete a key * * @access public * @param string $key * @param boolean $checkOwnership Check to see whether the user deleting owns the invite * @return boolean */ public function delete($key = null, $checkOwnership = true) { $invite = $this->get($key); if (!$key && !$invite) { return false; } $group = $this->Group->get($invite['group_id']); if ($checkOwnership) { if (!$this->Group->isOwner($group['id'], $this->userData['id'])) { return false; } } if (parent::delete($invite['key_hashed'], array('prefixValue' => 'key_hashed'))) { $group['invites'] = $this->removeFromArray($group['invites'], $invite['key']); return $this->Group->save($group); } }
/** * Delete a user's sms key * * @access public * @param int $user_id * @return boolean */ public function delete($user_id) { return parent::delete($user_id, array('prefixValue' => 'user_id')); }