public function __construct($record = null) { parent::__construct(); $this->record = $record; $this->model = new Placid_RequestsModel(); if (is_null($this->record)) { $this->record = Placid_RequestsRecord::model(); } // Get the plugin settings $this->placid_settings = $this->settings; }
/** * Return the request * * @param string $handle * * @param array $options * * @throws Exception * * @return mixed */ public function findRequestByHandle($handle) { Craft::log(__METHOD__, LogLevel::Info, true); // Get the request record by its handle // --------------------------------------------- $record = Placid_RequestsRecord::model()->find('handle=:handle', array(':handle' => $handle)); if ($record) { return Placid_RequestsModel::populateModel($record); } else { throw new Exception(Craft::t('Can\'t find request with handle "{handle}"', array('handle' => $handle))); } }
/** * Deletes a Widget based on the record * @param Int $id The id of the record * @return Bool True */ private function _deleteWidgetsByRecord($id) { $record = Placid_RequestsRecord::model()->findByPk($id); $currentWidgets = craft()->dashboard->getUserWidgets(); foreach ($currentWidgets as $widget) { $settings = $widget->settings; if ($settings && is_array($settings)) { if (array_key_exists('request', $settings) && $settings['request'] == $record->handle) { craft()->dashboard->deleteUserWidgetById($widget->id); } } } return true; }