From: Eileen McNaughton Date: Wed, 3 Jun 2015 00:35:09 +0000 (+1200) Subject: Remove Auction & Touchstone X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=bbd938320bb4d529c12dfc624a6b14c2a139b90c;p=civicrm-core.git Remove Auction & Touchstone Conflicts: tools/CRM/Auction/BAO/Auction.php tools/CRM/Auction/BAO/Item.php tools/CRM/Auction/Form/Auction.php tools/CRM/Auction/Form/Item.php --- diff --git a/tools/CRM/Auction/BAO/Auction.php b/tools/CRM/Auction/BAO/Auction.php deleted file mode 100644 index 92bd0de70e..0000000000 --- a/tools/CRM/Auction/BAO/Auction.php +++ /dev/null @@ -1,176 +0,0 @@ -copyValues($params); - if ($auction->find(TRUE)) { - CRM_Core_DAO::storeValues($auction, $defaults); - return $auction; - } - return NULL; - } - - /** - * update the is_active flag in the db - * - * @param int $id id of the database record - * @param boolean $is_active value we want to set the is_active field - * - * @return Object DAO object on sucess, null otherwise - */ - static function setIsActive($id, $is_active) { - return CRM_Core_DAO::setFieldValue('CRM_Auction_DAO_Auction', $id, 'is_active', $is_active); - } - - /** - * add the auction - * - * @param array $params reference array contains the values submitted by the form - * @return object - */ - static function add(&$params) { - if (!empty($params['id'])) { - CRM_Utils_Hook::pre('edit', 'Auction', $params['id'], $params); - } - else { - CRM_Utils_Hook::pre('create', 'Auction', NULL, $params); - } - - $auction = new CRM_Auction_DAO_Auction(); - - $auction->copyValues($params); - $result = $auction->save(); - - if (!empty($params['id'])) { - CRM_Utils_Hook::post('edit', 'Auction', $auction->id, $auction); - } - else { - CRM_Utils_Hook::post('create', 'Auction', $auction->id, $auction); - } - - return $result; - } - - /** - * create the auction - * - * @param array $params reference array contains the values submitted by the form - * - * @return object - */ - public static function create(&$params) { - $transaction = new CRM_Core_Transaction(); - - $auction = self::add($params); - - if (is_a($auction, 'CRM_Core_Error')) { - CRM_Core_DAO::transaction('ROLLBACK'); - return $auction; - } - - $transaction->commit(); - - return $auction; - } - - /** - * delete the auction - * - * @param int $id auction id - * - */ - static function del($id) { - $auction = new CRM_Auction_DAO_Auction(); - $auction->id = $id; - $result = $auction->delete(); - return $result; - } - - /** - * Function to get current/future Auctions - * - * @param $all boolean true if auctions all are required else returns current and future auctions - * - * @param bool $id - * - * @return array - */ - static function getAuctions($all = FALSE, $id = FALSE) { - $query = "SELECT `id`, `title`, `start_date` FROM `civicrm_auction`"; - - if (!$all) { - $endDate = date('YmdHis'); - $query .= " WHERE `end_date` >= {$endDate} OR end_date IS NULL"; - } - if ($id) { - $query .= " WHERE `id` = {$id}"; - } - - $query .= " ORDER BY title asc"; - $auctions = array(); - - $dao = &CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray); - while ($dao->fetch()) { - $auctions[$dao->id] = $dao->title . ' - ' . CRM_Utils_Date::customFormat($dao->start_date); - } - - return $auctions; - } -} - diff --git a/tools/CRM/Auction/BAO/Item.php b/tools/CRM/Auction/BAO/Item.php deleted file mode 100644 index 7e4320b005..0000000000 --- a/tools/CRM/Auction/BAO/Item.php +++ /dev/null @@ -1,179 +0,0 @@ -copyValues($params); - if ($auction->find(TRUE)) { - CRM_Core_DAO::storeValues($auction, $defaults); - return $auction; - } - return NULL; - } - - /** - * update the is_active flag in the db - * - * @param int $id id of the database record - * @param boolean $is_active value we want to set the is_active field - * - * @return Object DAO object on sucess, null otherwise - */ - static function setIsActive($id, $is_active) { - return CRM_Core_DAO::setFieldValue('CRM_Auction_DAO_Item', $id, 'is_active', $is_active); - } - - /** - * add the auction - * - * @param array $params reference array contains the values submitted by the form - * @return object - */ - static function add(&$params) { - if (!empty($params['id'])) { - CRM_Utils_Hook::pre('edit', 'Auction_Item', $params['id'], $params); - } - else { - CRM_Utils_Hook::pre('create', 'Auction_Item', NULL, $params); - } - - $auction = new CRM_Auction_DAO_Item(); - - $auction->copyValues($params); - $auction->save(); - - // add attachments as needed - CRM_Core_BAO_File::formatAttachment($params, - $params, - 'civicrm_auction_item', - $auction->id - ); - // add attachments as needed - CRM_Core_BAO_File::processAttachment($params, - 'civicrm_auction_item', - $auction->id - ); - - if (!empty($params['id'])) { - CRM_Utils_Hook::post('edit', 'Auction_Item', $auction->id, $auction); - } - else { - CRM_Utils_Hook::post('create', 'Auction_Item', $auction->id, $auction); - } - - return $result; - } - - /** - * create the auction - * - * @param array $params reference array contains the values submitted by the form - * - * @return object - */ - public static function create(&$params) { - $transaction = new CRM_Core_Transaction(); - - $auction = self::add($params); - - if (is_a($auction, 'CRM_Core_Error')) { - CRM_Core_DAO::transaction('ROLLBACK'); - return $auction; - } - - $transaction->commit(); - - return $auction; - } - - /** - * delete the auction - * - * @param int $id auction id - */ - static function del($id) { - $auction = new CRM_Auction_DAO_Item(); - $auction->id = $id; - $result = $auction->delete(); - return $result; - } - - /** - * Function to check if email is enabled for a given profile - * - * @param $profileId - * - * @internal param int $id profile id - * - * @return boolean - */ - static function isEmailInProfile($profileId) { - $query = " -SELECT field_name -FROM civicrm_uf_field -WHERE field_name like 'email%' And is_active = 1 And uf_group_id = %1"; - - $params = array(1 => array($profileId, 'Integer')); - $dao = CRM_Core_DAO::executeQuery($query, $params); - if (!$dao->fetch()) { - return TRUE; - } - return FALSE; - } -} - diff --git a/tools/CRM/Auction/Config.php b/tools/CRM/Auction/Config.php deleted file mode 100644 index 23761181ed..0000000000 --- a/tools/CRM/Auction/Config.php +++ /dev/null @@ -1,45 +0,0 @@ -_stateMachine = new CRM_Auction_StateMachine_Item($this, $action); - - // create and instantiate the pages - $this->addPages($this->_stateMachine, $action); - - // add all the actions - $uploadNames = $this->get('uploadNames'); - if (!empty($uploadNames)) { - $config = CRM_Core_Config::singleton(); - $this->addActions($config->customFileUploadDir, $uploadNames); - } - else { - $this->addActions(); - } - } -} - diff --git a/tools/CRM/Auction/Form/Auction.php b/tools/CRM/Auction/Form/Auction.php deleted file mode 100644 index 4cfb8354ed..0000000000 --- a/tools/CRM/Auction/Form/Auction.php +++ /dev/null @@ -1,245 +0,0 @@ -_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE); - - $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); - - if (!CRM_Core_Permission::checkActionPermission('CiviAuction', $this->_action)) { - CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); - } - - if (($this->_action & CRM_Core_Action::VIEW || - $this->_action & CRM_Core_Action::UPDATE || - $this->_action & CRM_Core_Action::DELETE - ) && - !$this->_id - ) { - CRM_Core_Error::fatal(); - } - } - - /** - * Set default values for the form. - * the default values are retrieved from the database - * @return array - */ - function setDefaultValues() { - - $defaults = array(); - - if (isset($this->_id)) { - $params = array('id' => $this->_id); - CRM_Auction_BAO_Auction::retrieve($params, $defaults); - } - else { - $defaults['is_active'] = 1; - } - - return $defaults; - } - - /** - * Build the form object - * - * @return array - */ - public function buildQuickForm() { - $this->applyFilter('__ALL__', 'trim'); - - $attributes = CRM_Core_DAO::getAttribute('CRM_Auction_DAO_Auction'); - $this->add('text', - 'title', - ts('Auction Title'), - $attributes['auction_title'], - TRUE - ); - - $this->addWysiwyg('description', - ts('Complete Description'), - $attributes['description'] - ); - - $this->_dates = array('start_date' => ts('Auction Start Date'), - 'end_date' => ts('Auction End Date'), - 'item_start_date' => ts('Upload Item Start Date'), - 'item_end_date' => ts('Upload Item End Date'), - ); - foreach ($this->_dates as $name => $title) { - $this->add('date', - $name, - $title, - CRM_Core_SelectValues::date('datetime') - ); - $this->addRule($name, ts('Please select a valid date.'), 'qfDate'); - } - - $this->_checkboxes = array('is_active' => ts('Is Active?'), - 'is_approval_needed' => ts('Do items need to be approved?'), - 'is_item_groups' => ts('Can items be grouped?'), - ); - - foreach ($this->_checkboxes as $name => $title) { - $this->addElement('checkbox', - $name, - $title - ); - } - - $this->_numbers = array('max_items_user' => ts('Maximum number of items per user'), - 'max_items' => ts('Maximum number of items for the auction'), - ); - foreach ($this->_numbers as $name => $title) { - $this->addElement('text', - $name, - $title, - $attributes[$name] - ); - $this->addRule($name, - ts('%1 should be a postive number', - array(1 => $title) - ), - 'positiveInteger' - ); - } - - if ($this->_action & CRM_Core_Action::VIEW) { - $buttons = array(array('type' => 'upload', - 'name' => ts('Done'), - 'spacing' => '         ', - 'isDefault' => TRUE, - )); - $this->freeze(); - } - elseif ($this->_action & CRM_Core_Action::DELETE) { - $this->freeze(); - $buttons = array(array('type' => 'upload', - 'name' => ts('Delete'), - 'spacing' => '         ', - 'isDefault' => TRUE, - ), - array('type' => 'cancel', - 'name' => ts('Cancel'), - ), - ); - } - else { - $buttons = array(array('type' => 'upload', - 'name' => ts('Save'), - 'spacing' => '         ', - 'isDefault' => TRUE, - ), - array('type' => 'cancel', - 'name' => ts('Cancel'), - ), - ); - } - $this->addButtons($buttons); - - $this->addFormRule(array('CRM_Auction_Form_Auction', 'formRule'), $this); - } - - /** - * global form rule - * - * @param array $fields the input form values - * @param array $files the uploaded files if any - * @param $self - * @return true if no errors, else array of errors - */ - static function formRule($fields, $files, $self) { - $errors = array(); - - // add rules to validate dates and overlap - return empty($errors) ? TRUE : $errors; - } - - /** - * Process the form submission - */ - public function postProcess() { - if ($this->_action & CRM_Core_Action::VIEW) { - return; - } - elseif ($this->_action & CRM_Core_Action::DELETE) { - CRM_Auction_BAO_Auction::del($this->_id); - return; - } - - $params = $this->controller->exportValues($this->_name); - - $params['id'] = $this->_id; - - // format date params - foreach ($this->_dates as $name => $title) { - $params[$name] = CRM_Utils_Date::format($params[$name]); - } - - // format checkboxes - foreach ($this->_checkboxes as $name => $title) { - $params[$name] = CRM_Utils_Array::value($name, $params, FALSE); - } - - CRM_Auction_BAO_Auction::add($params); - } -} - diff --git a/tools/CRM/Auction/Form/Item.php b/tools/CRM/Auction/Form/Item.php deleted file mode 100644 index 6633980e7e..0000000000 --- a/tools/CRM/Auction/Form/Item.php +++ /dev/null @@ -1,316 +0,0 @@ -_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add'); - - $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); - $this->_aid = CRM_Utils_Request::retrieve('aid', 'Positive', $this, TRUE); - - if (($this->_action & CRM_Core_Action::VIEW || - $this->_action & CRM_Core_Action::UPDATE || - $this->_action & CRM_Core_Action::DELETE - ) && - !$this->_id - ) { - CRM_Core_Error::fatal("I am not sure which item you looking for."); - } - - require_once 'CRM/Auction/BAO/Auction.php'; - $params = array('id' => $this->_aid); - $this->_auctionValues = array(); - CRM_Auction_BAO_Auction::retrieve($params, $this->_auctionValues); - - $this->assign('auctionTitle', $this->_auctionValues['auction_title']); - - // set donor id - $session = CRM_Core_Session::singleton(); - $this->_donorID = $this->get('donorID'); - - $this->assign('donorName', - CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', - $this->_donorID, - 'display_name' - ) - ); - - // also set user context - $session->pushUserContext(CRM_Utils_System::url('civicrm/auction/item', - "reset=1&aid={$this->_aid}" - )); - } - - /** - * Set default values for the form. - * the default values are retrieved from the database - * @return array - */ - function setDefaultValues() { - $defaults = array(); - - if (isset($this->_id)) { - $params = array('id' => $this->_id); - CRM_Auction_BAO_Item::retrieve($params, $defaults); - } - else { - $defaults['is_active'] = 1; - $defaults['auction_type_id'] = 1; - } - - return $defaults; - } - - /** - * Build the form object - */ - public function buildQuickForm() { - $this->applyFilter('__ALL__', 'trim'); - - $attributes = CRM_Core_DAO::getAttribute('CRM_Auction_DAO_Item'); - $this->add('text', - 'title', - ts('Item Label'), - $attributes['title'], - TRUE - ); - - $this->addWysiwyg('description', - ts('Complete Description'), - $attributes['description'] - ); - - $auctionTypes = CRM_Core_OptionGroup::values('auction_item_type'); - $this->add('select', 'auction_item_type_id', ts('Item Type'), - array('' => ts('- select -')) + $auctionTypes - ); - - $this->add('text', 'url', ts('Item URL'), - array_merge($attributes['description'], - array('onfocus' => "if (!this.value) { this.value='http://';} else return false", - 'onblur' => "if ( this.value == 'http://') { this.value='';} else return false", - ) - ) - ); - - - $this->_checkboxes = array('is_active' => ts('Is Active?'), - 'is_group' => ts('Does this item have other items associated with it?'), - ); - foreach ($this->_checkboxes as $name => $title) { - $this->addElement('checkbox', - $name, - $title - ); - } - - $this->_numbers = array('quantity' => ts('Number of units available'), - 'retail_value' => ts('Retail value of item'), - 'min_bid_value' => ts('Minimum bid accepted'), - 'min_bid_increment' => ts('Minimum bid increment'), - 'buy_now_value' => ts('Buy it now value'), - ); - - foreach ($this->_numbers as $name => $title) { - $this->addElement('text', - $name, - $title, - $attributes[$name] - ); - if ($name == 'quantity') { - $this->addRule($name, - ts('%1 should be a postive number', - array(1 => $title) - ), - 'positiveInteger' - ); - } - else { - $this->addRule($name, - ts('%1 should be a valid money value', - array(1 => $title) - ), - 'money' - ); - } - } - - $maxAttachments = 1; - require_once 'CRM/Core/BAO/File.php'; - CRM_Core_BAO_File::buildAttachment($this, 'civicrm_pcp', $this->_pageId, $maxAttachments); - - - if ($this->_action & CRM_Core_Action::VIEW) { - $buttons = array(array('type' => 'upload', - 'name' => ts('Done'), - 'spacing' => '         ', - 'isDefault' => TRUE, - )); - $this->freeze(); - } - elseif ($this->_action & CRM_Core_Action::DELETE) { - $this->freeze(); - $buttons = array(array('type' => 'upload', - 'name' => ts('Delete'), - 'spacing' => '         ', - 'isDefault' => TRUE, - ), - array('type' => 'cancel', - 'name' => ts('Cancel'), - ), - ); - } - else { - $buttons = array(array('type' => 'upload', - 'name' => ts('Save'), - 'spacing' => '         ', - 'isDefault' => TRUE, - )); - - $session = CRM_Core_Session::singleton(); - if ($session->get('userID')) { - $buttons[] = array('type' => 'next', - 'name' => ts('Save and New'), - 'subName' => 'new', - ); - } - $buttons[] = array('type' => 'cancel', - 'name' => ts('Cancel'), - ); - } - $this->addButtons($buttons); - - $this->addFormRule(array('CRM_Auction_Form_Item', 'formRule'), $this); - } - - /** - * global form rule - * - * @param array $fields the input form values - * @param array $files the uploaded files if any - * @param $self - * @return true if no errors, else array of errors - */ - static function formRule($fields, $files, $self) { - $errors = array(); - - if (isset($files['attachFile_1'])) { - list($width, $height) = getimagesize($files['attachFile_1']['tmp_name']); - if ($width > 360 || $height > 360) { - $errors['attachFile_1'] = "Your picture or image file can not be larger than 360 x 360 pixels in size." . " The dimensions of the image you've selected is " . $width . " x " . $height . ". Please shrink or crop the file or find another smaller image and try again."; - } - } - - return empty($errors) ? TRUE : $errors; - } - - /** - * Process the form submission - */ - public function postProcess() { - if ($this->_action & CRM_Core_Action::VIEW) { - return; - } - elseif ($this->_action & CRM_Core_Action::DELETE) { - CRM_Auction_BAO_Item::del($this->_id); - return; - } - - $params = $this->controller->exportValues($this->_name); - - $params['id'] = $this->_id; - $params['auction_id'] = $this->_aid; - - $params['donor_id'] = $this->_donorID; - - if ($this->_action == CRM_Core_Action::ADD) { - $params['creator_id'] = $this->_donorID; - $params['created_date'] = date('YmdHis'); - } - - // format checkboxes - foreach ($this->_checkboxes as $name => $title) { - $params[$name] = CRM_Utils_Array::value($name, $params, FALSE); - } - - // does this auction require approval - $params['is_approved'] = $this->_auctionValues['is_approval_needed'] ? 0 : 1; - - CRM_Auction_BAO_Item::add($params); - - if ($this->controller->getButtonName() == $this->getButtonName('next', 'new')) { - $session = CRM_Core_Session::singleton(); - //CRM_Core_Session::setStatus(ts(' You can add another profile field.')); - $session->replaceUserContext(CRM_Utils_System::url('civicrm/auction/item', - "reset=1&action=add&aid={$this->_aid}" - )); - } - } -} - diff --git a/tools/CRM/Auction/Form/ItemAccount.php b/tools/CRM/Auction/Form/ItemAccount.php deleted file mode 100644 index 9fe147cf0b..0000000000 --- a/tools/CRM/Auction/Form/ItemAccount.php +++ /dev/null @@ -1,215 +0,0 @@ -_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add'); - $this->_aid = CRM_Utils_Request::retrieve('aid', 'Positive', $this); - - if ($session->get('userID')) { - $this->_donorID = $session->get('userID'); - } - - if (!$this->_aid) { - $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE); - $this->_aid = CRM_Core_DAO::getFieldValue('CRM_Auction_DAO_Item', $this->_id, 'auction_id'); - } - - // we do not want to display recently viewed items, so turn off - $this->assign('displayRecent', FALSE); - } - - /** - * This virtual function is used to set the default values of - * various form elements - * @return array reference to the array of default values - */ - function setDefaultValues() { - if (!$this->_donorID) { - return; - } - - foreach ($this->_fields as $name => $dontcare) { - $fields[$name] = 1; - } - - require_once "CRM/Core/BAO/UFGroup.php"; - CRM_Core_BAO_UFGroup::setProfileDefaults($this->_donorID, $fields, $this->_defaults); - - //set custom field defaults - require_once "CRM/Core/BAO/CustomField.php"; - foreach ($this->_fields as $name => $field) { - if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) { - if (!isset($this->_defaults[$name])) { - CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $this->_defaults, - NULL, CRM_Profile_Form::MODE_REGISTER - ); - } - } - } - - return $this->_defaults; - } - - /** - * Build the form object - */ - public function buildQuickForm() { - $profileID = CRM_Core_DAO::getFieldValue('CRM_Auction_DAO_Auction', - $this->_aid, 'donor_profile_id' - ); - if (!$profileID) { - CRM_Core_Error::fatal('Profile not configured for this auction.'); - } - - require_once 'CRM/Auction/BAO/Item.php'; - if (CRM_Auction_BAO_Item::isEmailInProfile($profileID)) { - $this->assign('profileDisplay', TRUE); - } - - $fields = NULL; - require_once "CRM/Core/BAO/UFGroup.php"; - if ($this->_donorID) { - if (CRM_Core_BAO_UFGroup::filterUFGroups($profileID, $this->_donorID)) { - $fields = CRM_Core_BAO_UFGroup::getFields($profileID, FALSE, CRM_Core_Action::ADD); - } - $this->addFormRule(array('CRM_Auction_Form_ItemAccount', 'formRule'), $this); - } - else { - require_once 'CRM/Core/BAO/CMSUser.php'; - CRM_Core_BAO_CMSUser::buildForm($this, $profileID, TRUE); - - $fields = CRM_Core_BAO_UFGroup::getFields($profileID, FALSE, CRM_Core_Action::ADD); - } - - if ($fields) { - $this->assign('fields', $fields); - $addCaptcha = FALSE; - foreach ($fields as $key => $field) { - if (isset($field['data_type']) && $field['data_type'] == 'File') { - // ignore file upload fields - continue; - } - require_once "CRM/Core/BAO/UFGroup.php"; - require_once "CRM/Profile/Form.php"; - CRM_Core_BAO_UFGroup::buildProfile($this, $field, CRM_Profile_Form::MODE_CREATE); - $this->_fields[$key] = $field; - if ($field['add_captcha']) { - $addCaptcha = TRUE; - } - } - - if ($addCaptcha) { - require_once 'CRM/Utils/ReCAPTCHA.php'; - $captcha = &CRM_Utils_ReCAPTCHA::singleton(); - $captcha->add($this); - $this->assign("isCaptcha", TRUE); - } - } - - $button[] = array('type' => 'next', - 'name' => ts('Continue >>'), - 'spacing' => '         ', - 'isDefault' => TRUE, - ); - - $this->addButtons($button); - } - - /** - * global form rule - * - * @param array $fields the input form values - * @param array $files the uploaded files if any - * @param $self - * - * @return bool|array - */ - static function formRule($fields, $files, $self) { - $errors = array(); - foreach ($fields as $key => $value) { - if (strpos($key, 'email-') !== FALSE) { - $ufContactId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFMatch', $value, 'contact_id', 'uf_name'); - if ($ufContactId && $ufContactId != $self->_donorID) { - $errors[$key] = ts('There is already an user associated with this email address. Please enter different email address.'); - } - } - } - return empty($errors) ? TRUE : $errors; - } - - /** - * Process the form submission - */ - public function postProcess() { - $params = $this->controller->exportValues($this->getName()); - if (!$this->_donorID) { - foreach ($params as $key => $value) { - if (substr($key, 0, 5) == 'email' && !empty($value)) { - $params['email'] = $value; - } - } - } - $donorID = &CRM_Contact_BAO_Contact::createProfileContact($params, $this->_fields, - $this->_donorID, $addToGroups - ); - $this->set('donorID', $donorID); - - require_once "CRM/Contribute/BAO/Contribution/Utils.php"; - CRM_Contribute_BAO_Contribution_Utils::createCMSUser($params, $donorID, 'email'); - } -} - diff --git a/tools/CRM/Auction/Form/SearchAuction.php b/tools/CRM/Auction/Form/SearchAuction.php deleted file mode 100644 index ad18b6452c..0000000000 --- a/tools/CRM/Auction/Form/SearchAuction.php +++ /dev/null @@ -1,112 +0,0 @@ -_showHide = new CRM_Core_ShowHideBlocks(); - if (empty($defaults['auctionsByDates'])) { - $this->_showHide->addHide('id_fromToDates'); - } - - $this->_showHide->addToTemplate(); - return $defaults; - } - - /** - * Build the form object - * @return void - */ - public function buildQuickForm() { - $this->add('text', 'title', ts('Find'), - array(CRM_Core_DAO::getAttribute('CRM_Auction_DAO_Auction', 'title')) - ); - - $auctionsByDates = array(); - $searchOption = array(ts('Show Current and Upcoming Auctions'), ts('Search All or by Date Range')); - $this->addRadio('auctionsByDates', ts('Auctions by Dates'), $searchOption, array('onclick' => "return showHideByValue('auctionsByDates','1','id_fromToDates','block','radio',true);"), "
"); - - $this->add('date', 'start_date', ts('From'), CRM_Core_SelectValues::date('relative')); - $this->addRule('start_date', ts('Select a valid Auction FROM date.'), 'qfDate'); - - $this->add('date', 'end_date', ts('To'), CRM_Core_SelectValues::date('relative')); - $this->addRule('end_date', ts('Select a valid Auction TO date.'), 'qfDate'); - - $this->addButtons(array( - array('type' => 'refresh', - 'name' => ts('Search'), - 'isDefault' => TRUE, - ), - )); - } - - function postProcess() { - $params = $this->controller->exportValues($this->_name); - $parent = $this->controller->getParent(); - $parent->set('searchResult', 1); - if (!empty($params)) { - $fields = array('title', 'event_type_id', 'start_date', 'end_date', 'auctionsByDates'); - foreach ($fields as $field) { - if (isset($params[$field]) && - !CRM_Utils_System::isNull($params[$field]) - ) { - $parent->set($field, $params[$field]); - } - else { - $parent->set($field, NULL); - } - } - } - } -} - diff --git a/tools/CRM/Auction/Form/SearchItem.php b/tools/CRM/Auction/Form/SearchItem.php deleted file mode 100644 index e6a773ca99..0000000000 --- a/tools/CRM/Auction/Form/SearchItem.php +++ /dev/null @@ -1,101 +0,0 @@ -add('text', 'title', ts('Find'), - array(CRM_Core_DAO::getAttribute('CRM_Auction_DAO_Auction', 'title')) - ); - - $this->add('date', 'start_date', ts('From'), CRM_Core_SelectValues::date('relative')); - $this->addRule('start_date', ts('Select a valid Auction FROM date.'), 'qfDate'); - - $this->add('date', 'end_date', ts('To'), CRM_Core_SelectValues::date('relative')); - $this->addRule('end_date', ts('Select a valid Auction TO date.'), 'qfDate'); - - $this->addButtons(array( - array('type' => 'refresh', - 'name' => ts('Search'), - 'isDefault' => TRUE, - ), - )); - } - - /** - * - */ - function postProcess() { - $params = $this->controller->exportValues($this->_name); - $parent = $this->controller->getParent(); - $parent->set('searchResult', 1); - if (!empty($params)) { - $fields = array('title', 'item_type_id'); - foreach ($fields as $field) { - if (isset($params[$field]) && - !CRM_Utils_System::isNull($params[$field]) - ) { - $parent->set($field, $params[$field]); - } - else { - $parent->set($field, NULL); - } - } - } - } -} - diff --git a/tools/CRM/Auction/Info.php b/tools/CRM/Auction/Info.php deleted file mode 100644 index 8a58a5106b..0000000000 --- a/tools/CRM/Auction/Info.php +++ /dev/null @@ -1,136 +0,0 @@ - 'CiviAuction', - 'translatedName' => ts('CiviAuction'), - 'title' => ts('CiviCRM Auctions'), - 'search' => 0, - 'showActivitiesInCore' => 0, - ); - } - - - // docs inherited from interface - /** - * @return array - */ - public function getPermissions() { - return array('access CiviAuction', - 'add auction items', - 'approve auction items', - 'bid on auction items', - 'delete in CiviAuction', - ); - } - - /** - * Provides information about user dashboard element - * offered by this component. - * - * @return array collection of required dashboard settings, - * null if no element offered - */ - public function getUserDashboardElement() { - return array('name' => ts('Auctions'), - 'title' => ts('Your Winning Auction Item(s)'), - 'perm' => array('bid on auction items'), - 'weight' => 20, - ); - } - - /** - * Provides information about user dashboard element - * offered by this component. - * - * @return array|null collection of required dashboard settings, - * null if no element offered - */ - public function registerTab() { - return array('title' => ts('Auctions'), - 'id' => 'auction', - 'url' => 'auction', - 'weight' => 40, - ); - } - - /** - * Provides information about advanced search pane - * offered by this component. - * - * @return array collection of required pane settings, - * null if no element offered - */ - public function registerAdvancedSearchPane() { - return array('title' => ts('Auctions'), - 'weight' => 40, - ); - } - - /** - * Provides potential activity types that this - * component might want to register in activity history. - * Needs to be implemented in component's information - * class. - * - * @return array|null collection of activity types - */ - public function getActivityTypes() { - $types = array(); - return $types; - } - - /** - * @param $shortCuts - */ - public function creatNewShortcut(&$shortCuts) {} -} - diff --git a/tools/CRM/Auction/Page/AddItem.php b/tools/CRM/Auction/Page/AddItem.php deleted file mode 100644 index df16db3dfe..0000000000 --- a/tools/CRM/Auction/Page/AddItem.php +++ /dev/null @@ -1,93 +0,0 @@ - ts('Manage Items'), - 'url' => CRM_Utils_System::url(CRM_Utils_System::currentPath(), - 'reset=1' - ), - )); - // what action to take ? - if ($action & CRM_Core_Action::ADD) { - $session = CRM_Core_Session::singleton(); - if ($session->get('userID')) { - // For logged in user directly go to add/update item page. - $controller = new CRM_Core_Controller_Simple('CRM_Auction_Form_Item', - 'New Item', - $action - ); - $controller->set('donorID', $session->get('userID')); - } - else { - // For anonymous user go via account creation wizard. - require_once 'CRM/Auction/Controller/Item.php'; - $controller = new CRM_Auction_Controller_Item('New Item', $action); - } - return $controller->run(); - } - elseif ($action & CRM_Core_Action::UPDATE) { - $session = CRM_Core_Session::singleton(); - if ($session->get('userID')) { - $controller = new CRM_Core_Controller_Simple('CRM_Auction_Form_Item', - 'Update Item', - $action - ); - $controller->set('donorID', $session->get('userID')); - return $controller->run(); - } - } - - parent::run(); - } -} - diff --git a/tools/CRM/Auction/Page/DashBoard.php b/tools/CRM/Auction/Page/DashBoard.php deleted file mode 100644 index 66c30fb1ea..0000000000 --- a/tools/CRM/Auction/Page/DashBoard.php +++ /dev/null @@ -1,53 +0,0 @@ -assign('action', $action); - $id = CRM_Utils_Request::retrieve('id', 'Positive', - $this, FALSE, 0 - ); - - $this->_aid = CRM_Utils_Request::retrieve('aid', 'Positive', $this); - - // set breadcrumb to append to 2nd layer pages - $breadCrumb = array(array('title' => ts('Manage Items'), - 'url' => CRM_Utils_System::url(CRM_Utils_System::currentPath(), - 'reset=1' - ), - )); - - // what action to take ? - if ($action & CRM_Core_Action::DISABLE) { - require_once 'CRM/Auction/BAO/Auction.php'; - CRM_Auction_BAO_Auction::setIsActive($id, 0); - } - elseif ($action & CRM_Core_Action::ENABLE) { - require_once 'CRM/Auction/BAO/Auction.php'; - CRM_Auction_BAO_Auction::setIsActive($id, 1); - } - elseif ($action & CRM_Core_Action::DELETE) { - $session = CRM_Core_Session::singleton(); - $session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1&action=browse')); - $controller = new CRM_Core_Controller_Simple('CRM_Auction_Form_Auction_Delete', - 'Delete Auction', - $action - ); - $id = CRM_Utils_Request::retrieve('id', 'Positive', - $this, FALSE, 0 - ); - $controller->set('id', $id); - $controller->process(); - return $controller->run(); - } - - // finally browse the auctions - $this->browse(); - - // parent run - parent::run(); - } - - /** - * Browse all auctions - * - * @return void - */ - function browse() { - if ($this->_aid) { - $this->assign('manageItemURL', CRM_Utils_System::url('civicrm/auction/item/manage', - 'reset=1&aid=' . $this->_aid - )); - } - - $this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter', - 'String', - $this - ); - if ($this->_sortByCharacter == 1 || - !empty($_POST) - ) { - $this->_sortByCharacter = ''; - $this->set('sortByCharacter', ''); - } - - $this->_force = NULL; - $this->_searchResult = NULL; - - $this->search(); - - $config = CRM_Core_Config::singleton(); - - $params = array(); - $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', - $this, FALSE - ); - $this->_searchResult = CRM_Utils_Request::retrieve('searchResult', 'Boolean', $this); - - $whereClause = $this->whereClause($params, FALSE, $this->_force); - $this->pagerAToZ($whereClause, $params); - - $params = array(); - $whereClause = $this->whereClause($params, TRUE, $this->_force); - $this->pager($whereClause, $params); - list($offset, $rowCount) = $this->_pager->getOffsetAndRowCount(); - - if ($this->_aid) { - $whereClause .= " AND auction_id = {$this->_aid}"; - } - - $query = " - SELECT i.*, c.display_name as donorName, max(b.bid_value) as maxBid - FROM civicrm_auction_item i - INNER JOIN civicrm_contact c ON i.donor_id = c.id - LEFT JOIN civicrm_auction_bid b ON i.id = b.auction_item_id - WHERE $whereClause - GROUP BY i.id - LIMIT $offset, $rowCount"; - - $dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Auction_DAO_Item'); - - // get all custom groups sorted by weight - $items = array(); - $auctionItemTypes = CRM_Core_OptionGroup::values('auction_item_type'); - while ($dao->fetch()) { - $items[$dao->id] = array(); - CRM_Core_DAO::storeValues($dao, $items[$dao->id]); - - $items[$dao->id]['donorName'] = $dao->donorName; - $items[$dao->id]['auction_item_type'] = CRM_Utils_Array::value($dao->auction_type_id, $auctionItemTypes); - $items[$dao->id]['max_bid'] = $dao->maxBid; - } - $this->assign('rows', $items); - } - - function search() { - $form = new CRM_Core_Controller_Simple('CRM_Auction_Form_SearchAuction', ts('Search Auctions'), CRM_Core_Action::ADD); - $form->setEmbedded(TRUE); - $form->setParent($this); - $form->process(); - $form->run(); - } - - /** - * @param array $params - * @param bool $sortBy - * @param $force - * - * @return int|string - */ - function whereClause(&$params, $sortBy = TRUE, $force) { - $values = array(); - $clauses = array(); - $title = $this->get('title'); - if ($title) { - $clauses[] = "title LIKE %1"; - if (strpos($title, '%') !== FALSE) { - $params[1] = array(trim($title), 'String', FALSE); - } - else { - $params[1] = array(trim($title), 'String', TRUE); - } - } - - if ($sortBy && - $this->_sortByCharacter - ) { - $clauses[] = 'title LIKE %6'; - $params[6] = array($this->_sortByCharacter . '%', 'String'); - } - - // dont do a the below assignment when doing a - // AtoZ pager clause - if ($sortBy) { - if (count($clauses) > 1) { - $this->assign('isSearch', 1); - } - else { - $this->assign('isSearch', 0); - } - } - - if (empty($clauses)) { - return 1; - } - - return implode(' AND ', $clauses); - } - - /** - * @param $whereClause - * @param $whereParams - */ - function pager($whereClause, $whereParams) { - require_once 'CRM/Utils/Pager.php'; - - $params['status'] = ts('Item %%StatusMessage%%'); - $params['csvString'] = NULL; - $params['buttonTop'] = 'PagerTopButton'; - $params['buttonBottom'] = 'PagerBottomButton'; - $params['rowCount'] = $this->get(CRM_Utils_Pager::PAGE_ROWCOUNT); - if (!$params['rowCount']) { - $params['rowCount'] = CRM_Utils_Pager::ROWCOUNT; - } - - $query = " -SELECT count(id) - FROM civicrm_auction_item - WHERE $whereClause"; - - $params['total'] = CRM_Core_DAO::singleValueQuery($query, $whereParams); - - $this->_pager = new CRM_Utils_Pager($params); - $this->assign_by_ref('pager', $this->_pager); - } - - /** - * @param $whereClause - * @param $whereParams - */ - function pagerAtoZ($whereClause, $whereParams) { - require_once 'CRM/Utils/PagerAToZ.php'; - - $query = " - SELECT DISTINCT UPPER(LEFT(title, 1)) as sort_name - FROM civicrm_auction_item - WHERE $whereClause - ORDER BY LEFT(title, 1) -"; - $dao = CRM_Core_DAO::executeQuery($query, $whereParams); - - $aToZBar = CRM_Utils_PagerAToZ::getAToZBar($dao, $this->_sortByCharacter, TRUE); - $this->assign('aToZ', $aToZBar); - } -} - diff --git a/tools/CRM/Auction/Page/Manage.php b/tools/CRM/Auction/Page/Manage.php deleted file mode 100644 index eeb367908a..0000000000 --- a/tools/CRM/Auction/Page/Manage.php +++ /dev/null @@ -1,350 +0,0 @@ - array( - 'name' => ts('Edit'), - 'url' => 'civicrm/auction/add', - 'qs' => 'action=update&id=%%id%%&reset=1', - 'title' => ts('Edit Auction'), - ), - CRM_Core_Action::PREVIEW => array( - 'name' => ts('Items'), - 'url' => 'civicrm/auction/item/manage', - 'qs' => 'aid=%%id%%&reset=1', - 'title' => ts('Manage Items'), - ), - CRM_Core_Action::DISABLE => array( - 'name' => ts('Disable'), - 'url' => CRM_Utils_System::currentPath(), - 'qs' => 'action=disable&id=%%id%%', - 'extra' => 'onclick = "return confirm(\'' . $disableExtra . '\');"', - 'title' => ts('Disable Auction'), - ), - CRM_Core_Action::ENABLE => array( - 'name' => ts('Enable'), - 'url' => CRM_Utils_System::currentPath(), - 'qs' => 'action=enable&id=%%id%%', - 'title' => ts('Enable Auction'), - ), - CRM_Core_Action::DELETE => array( - 'name' => ts('Delete'), - 'url' => 'civicrm/auction/item/add', - 'qs' => 'action=delete&id=%%id%%&reset=1', - 'extra' => 'onclick = "return confirm(\'' . $deleteExtra . '\');"', - 'title' => ts('Delete Auction'), - ), - CRM_Core_Action::COPY => array( - 'name' => ts('Copy Auction'), - 'url' => CRM_Utils_System::currentPath(), - 'qs' => 'reset=1&action=copy&id=%%id%%', - 'extra' => 'onclick = "return confirm(\'' . $copyExtra . '\');"', - 'title' => ts('Copy Auction'), - ), - ); - } - return self::$_actionLinks; - } - - /** - * Run the page. - * - * This method is called after the page is created. It checks for the - * type of action and executes that action. - * Finally it calls the parent's run method. - * - * @return void - */ - function run() { - // get the requested action - $action = CRM_Utils_Request::retrieve('action', 'String', - // default to 'browse' - $this, FALSE, 'browse' - ); - - // assign vars to templates - $this->assign('action', $action); - $id = CRM_Utils_Request::retrieve('id', 'Positive', - $this, FALSE, 0 - ); - - // set breadcrumb to append to 2nd layer pages - $breadCrumb = array(array('title' => ts('Manage Items'), - 'url' => CRM_Utils_System::url(CRM_Utils_System::currentPath(), - 'reset=1' - ), - )); - - // what action to take ? - if ($action & CRM_Core_Action::DISABLE) { - require_once 'CRM/Auction/BAO/Item.php'; - CRM_Auction_BAO_Item::setIsActive($id, 0); - } - elseif ($action & CRM_Core_Action::ENABLE) { - require_once 'CRM/Auction/BAO/Item.php'; - CRM_Auction_BAO_Item::setIsActive($id, 1); - } - elseif ($action & CRM_Core_Action::DELETE) { - $session = CRM_Core_Session::singleton(); - $session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1&action=browse')); - $controller = new CRM_Core_Controller_Simple('CRM_Auction_Form_Item_Delete', - 'Delete Item', - $action - ); - $id = CRM_Utils_Request::retrieve('id', 'Positive', - $this, FALSE, 0 - ); - $controller->set('id', $id); - $controller->process(); - return $controller->run(); - } - elseif ($action & CRM_Core_Action::COPY) { - $this->copy(); - } - - // finally browse the auctions - $this->browse(); - - // parent run - parent::run(); - } - - /** - * Browse all auctions - * - * @return void - */ - function browse() { - - $this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter', - 'String', - $this - ); - if ($this->_sortByCharacter == 1 || - !empty($_POST) - ) { - $this->_sortByCharacter = ''; - $this->set('sortByCharacter', ''); - } - - $this->_force = NULL; - $this->_searchResult = NULL; - - $this->search(); - - $config = CRM_Core_Config::singleton(); - - $params = array(); - $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', - $this, FALSE - ); - $this->_searchResult = CRM_Utils_Request::retrieve('searchResult', 'Boolean', $this); - - $whereClause = $this->whereClause($params, FALSE, $this->_force); - $this->pagerAToZ($whereClause, $params); - - $params = array(); - $whereClause = $this->whereClause($params, TRUE, $this->_force); - $this->pager($whereClause, $params); - list($offset, $rowCount) = $this->_pager->getOffsetAndRowCount(); - - // get all custom groups sorted by weight - $auctions = array(); - - $query = " - SELECT * - FROM civicrm_auction - WHERE $whereClause -ORDER BY start_date desc - LIMIT $offset, $rowCount"; - - $dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Auction_DAO_Item'); - - while ($dao->fetch()) { - $auctions[$dao->id] = array(); - CRM_Core_DAO::storeValues($dao, $auctions[$dao->id]); - - // form all action links - $action = array_sum(array_keys($this->links())); - - if ($dao->is_active) { - $action -= CRM_Core_Action::ENABLE; - } - else { - $action -= CRM_Core_Action::DISABLE; - } - - $auctions[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, - array('id' => $dao->id) - ); - } - $this->assign('rows', $auctions); - } - - /** - * - */ - function search() { - $form = new CRM_Core_Controller_Simple('CRM_Auction_Form_SearchAuction', - ts('Search Items'), CRM_Core_Action::ADD - ); - $form->setEmbedded(TRUE); - $form->setParent($this); - $form->process(); - $form->run(); - } - - /** - * @param array $params - * @param bool $sortBy - * @param $force - * - * @return int|string - */ - function whereClause(&$params, $sortBy = TRUE, $force) { - $values = array(); - $clauses = array(); - $title = $this->get('title'); - if ($title) { - $clauses[] = "title LIKE %1"; - if (strpos($title, '%') !== FALSE) { - $params[1] = array(trim($title), 'String', FALSE); - } - else { - $params[1] = array(trim($title), 'String', TRUE); - } - } - - if ($sortBy && - $this->_sortByCharacter - ) { - $clauses[] = 'title LIKE %6'; - $params[6] = array($this->_sortByCharacter . '%', 'String'); - } - - // dont do a the below assignment when doing a - // AtoZ pager clause - if ($sortBy) { - if (count($clauses) > 1 || $auctionByDates) { - $this->assign('isSearch', 1); - } - else { - $this->assign('isSearch', 0); - } - } - - if (empty($clauses)) { - return 1; - } - - return implode(' AND ', $clauses); - } - - /** - * @param $whereClause - * @param $whereParams - */ - function pager($whereClause, $whereParams) { - require_once 'CRM/Utils/Pager.php'; - - $params['status'] = ts('Item %%StatusMessage%%'); - $params['csvString'] = NULL; - $params['buttonTop'] = 'PagerTopButton'; - $params['buttonBottom'] = 'PagerBottomButton'; - $params['rowCount'] = $this->get(CRM_Utils_Pager::PAGE_ROWCOUNT); - if (!$params['rowCount']) { - $params['rowCount'] = CRM_Utils_Pager::ROWCOUNT; - } - - $query = " -SELECT count(id) - FROM civicrm_auction - WHERE $whereClause"; - - $params['total'] = CRM_Core_DAO::singleValueQuery($query, $whereParams); - - $this->_pager = new CRM_Utils_Pager($params); - $this->assign_by_ref('pager', $this->_pager); - } - - /** - * @param $whereClause - * @param $whereParams - */ - function pagerAtoZ($whereClause, $whereParams) { - require_once 'CRM/Utils/PagerAToZ.php'; - - $query = " - SELECT DISTINCT UPPER(LEFT(title, 1)) as sort_name - FROM civicrm_auction - WHERE $whereClause - ORDER BY LEFT(title, 1) -"; - $dao = CRM_Core_DAO::executeQuery($query, $whereParams); - - $aToZBar = CRM_Utils_PagerAToZ::getAToZBar($dao, $this->_sortByCharacter, TRUE); - $this->assign('aToZ', $aToZBar); - } -} diff --git a/tools/CRM/Auction/Page/ManageItem.php b/tools/CRM/Auction/Page/ManageItem.php deleted file mode 100644 index 245ebadd48..0000000000 --- a/tools/CRM/Auction/Page/ManageItem.php +++ /dev/null @@ -1,379 +0,0 @@ - array( - 'name' => ts('Edit'), - 'url' => 'civicrm/auction/item/add', - 'qs' => 'action=update&id=%%id%%&aid=%%aid%%&reset=1', - 'title' => ts('Edit Item'), - ), - CRM_Core_Action::DISABLE => array( - 'name' => ts('Reject'), - 'url' => CRM_Utils_System::currentPath(), - 'qs' => 'action=disable&id=%%id%%&aid=%%aid%%', - 'extra' => 'onclick = "return confirm(\'' . $disableExtra . '\');"', - 'title' => ts('Disable Item'), - ), - CRM_Core_Action::ENABLE => array( - 'name' => ts('Approve'), - 'url' => CRM_Utils_System::currentPath(), - 'qs' => 'action=enable&id=%%id%%&aid=%%aid%%', - 'title' => ts('Enable Item'), - ), - CRM_Core_Action::DELETE => array( - 'name' => ts('Delete'), - 'url' => 'civicrm/auction/item/add', - 'qs' => 'action=delete&id=%%id%%&aid=%%aid%%&reset=1', - 'extra' => 'onclick = "return confirm(\'' . $deleteExtra . '\');"', - 'title' => ts('Delete Item'), - ), - ); - } - return self::$_actionLinks; - } - - /** - * Run the page. - * - * This method is called after the page is created. It checks for the - * type of action and executes that action. - * Finally it calls the parent's run method. - * - * @return void - */ - function run() { - // get the requested action - $action = CRM_Utils_Request::retrieve('action', 'String', - // default to 'browse' - $this, FALSE, 'browse' - ); - - // assign vars to templates - $this->assign('action', $action); - $id = CRM_Utils_Request::retrieve('id', 'Positive', - $this, FALSE, 0 - ); - - $this->_aid = CRM_Utils_Request::retrieve('aid', 'Positive', $this, TRUE); - - // set breadcrumb to append to 2nd layer pages - $breadCrumb = array(array('title' => ts('Manage Items'), - 'url' => CRM_Utils_System::url(CRM_Utils_System::currentPath(), - 'reset=1' - ), - )); - - // what action to take ? - if ($action & CRM_Core_Action::DISABLE) { - require_once 'CRM/Auction/BAO/Item.php'; - CRM_Auction_BAO_Item::setIsActive($id, 0); - } - elseif ($action & CRM_Core_Action::ENABLE) { - require_once 'CRM/Auction/BAO/Item.php'; - CRM_Auction_BAO_Item::setIsActive($id, 1); - } - elseif ($action & CRM_Core_Action::DELETE) { - $session = CRM_Core_Session::singleton(); - $session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1&action=browse')); - $controller = new CRM_Core_Controller_Simple('CRM_Auction_Form_Auction_Delete', - 'Delete Auction', - $action - ); - $id = CRM_Utils_Request::retrieve('id', 'Positive', - $this, FALSE, 0 - ); - $controller->set('id', $id); - $controller->process(); - return $controller->run(); - } - elseif ($action & CRM_Core_Action::COPY) { - $this->copy(); - } - - // finally browse the auctions - $this->browse(); - - // parent run - parent::run(); - } - - /** - * Browse all auctions - * - * @return void - */ - function browse() { - $this->assign('newItemURL', CRM_Utils_System::url('civicrm/auction/item/add', - 'reset=1&action=add&aid=' . $this->_aid - )); - $this->assign('previewItemURL', CRM_Utils_System::url('civicrm/auction/item', - 'reset=1&aid=' . $this->_aid - )); - - $this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter', - 'String', - $this - ); - if ($this->_sortByCharacter == 1 || - !empty($_POST) - ) { - $this->_sortByCharacter = ''; - $this->set('sortByCharacter', ''); - } - - $this->_force = NULL; - $this->_searchResult = NULL; - - $this->search(); - - $config = CRM_Core_Config::singleton(); - - $params = array(); - $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', - $this, FALSE - ); - $this->_searchResult = CRM_Utils_Request::retrieve('searchResult', 'Boolean', $this); - - $whereClause = $this->whereClause($params, FALSE, $this->_force); - $this->pagerAToZ($whereClause, $params); - - $params = array(); - $whereClause = $this->whereClause($params, TRUE, $this->_force); - $this->pager($whereClause, $params); - list($offset, $rowCount) = $this->_pager->getOffsetAndRowCount(); - - //check for delete CRM-4418 - require_once 'CRM/Core/Permission.php'; - $allowToDelete = CRM_Core_Permission::check('delete in CiviAuction'); - - $query = " - SELECT i.*, c.display_name as donorName - FROM civicrm_auction_item i, - civicrm_contact c - WHERE $whereClause - AND auction_id = {$this->_aid} - AND i.donor_id = c.id - LIMIT $offset, $rowCount"; - - $dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Auction_DAO_Item'); - - // get all custom groups sorted by weight - $items = array(); - $auctionItemTypes = CRM_Core_OptionGroup::values('auction_item_type'); - while ($dao->fetch()) { - $items[$dao->id] = array(); - CRM_Core_DAO::storeValues($dao, $items[$dao->id]); - - $items[$dao->id]['donorName'] = $dao->donorName; - $items[$dao->id]['auction_item_type'] = CRM_Utils_Array::value($dao->auction_type_id, $auctionItemTypes); - - // form all action links - $action = array_sum(array_keys($this->links())); - - if ($dao->is_active) { - $action -= CRM_Core_Action::ENABLE; - } - else { - $action -= CRM_Core_Action::DISABLE; - } - //check for delete - if (!$allowToDelete) { - $action -= CRM_Core_Action::DELETE; - } - - $items[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), - $action, - array('id' => $dao->id, - 'aid' => $this->_aid, - ) - ); - } - $this->assign('rows', $items); - } - - /** - * This function is to make a copy of a Auction, including - * all the fields in the event wizard - * - * @return void - */ - function copy() { - $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE, 0, 'GET'); - - require_once 'CRM/Auction/BAO/Auction.php'; - CRM_Auction_BAO_Auction::copy($id); - - return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/manage', 'reset=1')); - } - - function search() { - $form = new CRM_Core_Controller_Simple('CRM_Auction_Form_SearchAuction', ts('Search Auctions'), CRM_Core_Action::ADD); - $form->setEmbedded(TRUE); - $form->setParent($this); - $form->process(); - $form->run(); - } - - /** - * @param array $params - * @param bool $sortBy - * @param $force - * - * @return int|string - */ - function whereClause(&$params, $sortBy = TRUE, $force) { - $values = array(); - $clauses = array(); - $title = $this->get('title'); - if ($title) { - $clauses[] = "title LIKE %1"; - if (strpos($title, '%') !== FALSE) { - $params[1] = array(trim($title), 'String', FALSE); - } - else { - $params[1] = array(trim($title), 'String', TRUE); - } - } - - if ($sortBy && - $this->_sortByCharacter - ) { - $clauses[] = 'title LIKE %6'; - $params[6] = array($this->_sortByCharacter . '%', 'String'); - } - - // dont do a the below assignment when doing a - // AtoZ pager clause - if ($sortBy) { - if (count($clauses) > 1) { - $this->assign('isSearch', 1); - } - else { - $this->assign('isSearch', 0); - } - } - - if (empty($clauses)) { - return 1; - } - - return implode(' AND ', $clauses); - } - - /** - * @param $whereClause - * @param $whereParams - */ - function pager($whereClause, $whereParams) { - require_once 'CRM/Utils/Pager.php'; - - $params['status'] = ts('Item %%StatusMessage%%'); - $params['csvString'] = NULL; - $params['buttonTop'] = 'PagerTopButton'; - $params['buttonBottom'] = 'PagerBottomButton'; - $params['rowCount'] = $this->get(CRM_Utils_Pager::PAGE_ROWCOUNT); - if (!$params['rowCount']) { - $params['rowCount'] = CRM_Utils_Pager::ROWCOUNT; - } - - $query = " -SELECT count(id) - FROM civicrm_auction_item - WHERE $whereClause"; - - $params['total'] = CRM_Core_DAO::singleValueQuery($query, $whereParams); - - $this->_pager = new CRM_Utils_Pager($params); - $this->assign_by_ref('pager', $this->_pager); - } - - /** - * @param $whereClause - * @param $whereParams - */ - function pagerAtoZ($whereClause, $whereParams) { - require_once 'CRM/Utils/PagerAToZ.php'; - - $query = " - SELECT DISTINCT UPPER(LEFT(title, 1)) as sort_name - FROM civicrm_auction_item - WHERE $whereClause - ORDER BY LEFT(title, 1) -"; - $dao = CRM_Core_DAO::executeQuery($query, $whereParams); - - $aToZBar = CRM_Utils_PagerAToZ::getAToZBar($dao, $this->_sortByCharacter, TRUE); - $this->assign('aToZ', $aToZBar); - } -} - diff --git a/tools/CRM/Auction/StateMachine/Item.php b/tools/CRM/Auction/StateMachine/Item.php deleted file mode 100644 index f79a519024..0000000000 --- a/tools/CRM/Auction/StateMachine/Item.php +++ /dev/null @@ -1,67 +0,0 @@ -set('singleForm', FALSE); - - $this->_pages = array( - 'CRM_Auction_Form_ItemAccount' => NULL, - 'CRM_Auction_Form_Item' => NULL, - ); - - $this->addSequentialPages($this->_pages, $action); - } -} - diff --git a/tools/CRM/Auction/xml/Menu/Auction.xml b/tools/CRM/Auction/xml/Menu/Auction.xml deleted file mode 100644 index c3cb3e4776..0000000000 --- a/tools/CRM/Auction/xml/Menu/Auction.xml +++ /dev/null @@ -1,99 +0,0 @@ - - - - - civicrm/auction - CiviAuction - CRM_Auction_Page_DashBoard - access CiviAuction - 1 - 1000 - CiviAuction - - - civicrm/auction/info - CRM_Auction_Page_AuctionInfo - Auction Information - 1 - true - - - civicrm/auction/item - Item Listing - CRM_Auction_Page_Item - 1 - true - true - - - civicrm/auction/item/manage - Auction Item - CRM_Auction_Page_ManageItem - 1 - true - true - - - civicrm/auction/item/add - Auction Item - CRM_Auction_Page_AddItem - 1 - true - true - - - civicrm/admin/auction - Manage Auctions - CRM_Auction_Page_Manage - Create and edit auction configuration including times. - access CiviAuction - CiviAuction - admin/small/auction_manage.png - 370 - - - civicrm/admin/auction/add - Add Auctions - CRM_Auction_Form_Auction - Create and edit auction configuration including times. - access CiviAuction - CiviAuction - admin/small/auction_manage.png - 370 - - - civicrm/admin/options/auction_type - Auction Types - CRM_Admin_Page_Options - Use Auction Types to categorize your auction items. - administer CiviCRM,access CiviAuction - CiviAuction - admin/small/auction_type.png - 375 - - - civicrm/auction/search - Find Auction Items - CRM_Auction_Controller_Search - access CiviAuction - 1 - 1010 - - - civicrm/auction/manage - Manage Auctions - CRM_Auction_Page_Manage - access CiviAuction - 1 - 1020 - - - civicrm/auction/add - action=add - New Auction - CRM_Auction_Form_Auction - access CiviAuction - 1 - 1030 - - diff --git a/tools/CRM/Touchstone/Config.php b/tools/CRM/Touchstone/Config.php deleted file mode 100644 index ccedbc64a1..0000000000 --- a/tools/CRM/Touchstone/Config.php +++ /dev/null @@ -1,46 +0,0 @@ - 'CiviTouchstone', - 'translatedName' => ts('CiviTouchstone'), - 'title' => ts('CiviCRM Touchstone Component'), - 'search' => 1, - ); - } - - /** - * @return array - */ - public function getPermissions() { - return array('access CiviTouchstone'); - } - - /** - * Provides information about user dashboard element - * offered by this component. - * - * @return array|null collection of required dashboard settings, - * null if no element offered - */ - public function getUserDashboardElement() { - return array('name' => ts('Touchstone'), - 'title' => ts('Your Touchstone'), - 'perm' => array('access CiviTouchstone'), - 'weight' => 85, - ); - } - - /** - * Provides information about user dashboard element - * offered by this component. - * - * @return array|null collection of required dashboard settings, - * null if no element offered - */ - public function registerTab() { - return array('title' => ts('Touchstone'), - 'url' => 'touchstone', - 'weight' => 25, - ); - } - - /** - * Provides information about advanced search pane - * offered by this component. - * - * @return array|null collection of required pane settings, - * null if no element offered - */ - public function registerAdvancedSearchPane() { - return array('title' => ts('Touchstone'), - 'weight' => 25, - ); - } - - /** - * Provides potential activity types that this - * component might want to register in activity history. - * Needs to be implemented in component's information - * class. - * - * @return array|null collection of activity types - */ - public function getActivityTypes() { - return NULL; - } - - /** - * @param $shortCuts - */ - public function creatNewShortcut(&$shortCuts) {} -} - diff --git a/tools/CRM/Touchstone/PseudoConstant.php b/tools/CRM/Touchstone/PseudoConstant.php deleted file mode 100644 index cb2ba9b021..0000000000 --- a/tools/CRM/Touchstone/PseudoConstant.php +++ /dev/null @@ -1,58 +0,0 @@ - ts('Perform First Task'), - 2 => ts('Perform Second Task'), - 5 => ts('Perform Third Task'), - ); - } - return self::$_tasks; - } -} -