当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Price_BAO_Set::getUsedBy方法代码示例

本文整理汇总了PHP中CRM_Price_BAO_Set::getUsedBy方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Price_BAO_Set::getUsedBy方法的具体用法?PHP CRM_Price_BAO_Set::getUsedBy怎么用?PHP CRM_Price_BAO_Set::getUsedBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Price_BAO_Set的用法示例。


在下文中一共展示了CRM_Price_BAO_Set::getUsedBy方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 /**
  * 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.
  * 
  * @param null
  * 
  * @return void
  * @access public
  *
  */
 function run()
 {
     // get the requested action
     $action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'browse');
     // default to 'browse'
     // assign vars to templates
     $this->assign('action', $action);
     $sid = CRM_Utils_Request::retrieve('sid', 'Positive', $this, false, 0);
     if ($sid) {
         require_once 'CRM/Price/BAO/Set.php';
         CRM_Price_BAO_Set::checkPermission($sid);
     }
     // what action to take ?
     if ($action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) {
         $this->edit($sid, $action);
     } else {
         if ($action & CRM_Core_Action::PREVIEW) {
             $this->preview($sid);
         } else {
             if ($action & CRM_Core_Action::COPY) {
                 $session = CRM_Core_Session::singleton();
                 CRM_Core_Session::setStatus("A copy of the price set has been created");
                 $this->copy();
             } else {
                 require_once 'CRM/Price/BAO/Set.php';
                 require_once 'CRM/Price/BAO/Field.php';
                 // if action is delete do the needful.
                 if ($action & CRM_Core_Action::DELETE) {
                     $usedBy =& CRM_Price_BAO_Set::getUsedBy($sid);
                     if (empty($usedBy)) {
                         // prompt to delete
                         $session =& CRM_Core_Session::singleton();
                         $session->pushUserContext(CRM_Utils_System::url('civicrm/admin/price', 'action=browse'));
                         $controller = new CRM_Core_Controller_Simple('CRM_Price_Form_DeleteSet', 'Delete Price Set', null);
                         // $id = CRM_Utils_Request::retrieve('sid', 'Positive', $this, false, 0);
                         $controller->set('sid', $sid);
                         $controller->setEmbedded(true);
                         $controller->process();
                         $controller->run();
                     } else {
                         // add breadcrumb
                         $url = CRM_Utils_System::url('civicrm/admin/price', 'reset=1');
                         CRM_Utils_System::appendBreadCrumb(ts('Price Sets'), $url);
                         $this->assign('usedPriceSetTitle', CRM_Price_BAO_Set::getTitle($sid));
                         $this->assign('usedBy', $usedBy);
                         $comps = array("Event" => "civicrm_event", "Contribution" => "civicrm_contribution_page");
                         $priceSetContexts = array();
                         foreach ($comps as $name => $table) {
                             if (array_key_exists($table, $usedBy)) {
                                 $priceSetContexts[] = $name;
                             }
                         }
                         $this->assign('contexts', $priceSetContexts);
                     }
                 }
                 // finally browse the price sets
                 $this->browse();
             }
         }
     }
     // parent run
     parent::run();
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:76,代码来源:Set.php

示例2: civicrm_api3_price_set_get

/**
 * Returns array of price_sets  matching a set of one or more group properties
 *
 * @param array $params Array of one or more valid property_name=>value pairs. If $params is set
 *  as null, all price_sets will be returned (default limit is 25)
 *
 * @return array  Array of matching price_sets
 * {@getfields price_set_get}
 * @access public
 */
function civicrm_api3_price_set_get($params)
{
    $result = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE);
    // Fetch associated entities
    foreach ($result as &$item) {
        $item['entity'] = CRM_Price_BAO_Set::getUsedBy($item['id'], 'entity');
    }
    return civicrm_api3_create_success($result, $params);
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:19,代码来源:PriceSet.php

示例3: edit

 /**
  * edit custom Option.
  *
  * editing would involved modifying existing fields + adding data to new fields.
  *
  * @param string  $action   the action to be invoked
  *
  * @return void
  * @access public
  */
 function edit($action)
 {
     $oid = CRM_Utils_Request::retrieve('oid', 'Positive', $this, FALSE, 0);
     $params = array();
     if ($oid) {
         $params['oid'] = $oid;
         $sid = CRM_Price_BAO_Set::getSetId($params);
         $usedBy = CRM_Price_BAO_Set::getUsedBy($sid);
     }
     // set the userContext stack
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url('civicrm/admin/price/field/option', "reset=1&action=browse&fid={$this->_fid}&sid={$this->_sid}"));
     $controller = new CRM_Core_Controller_Simple('CRM_Price_Form_Option', ts('Price Field Option'), $action);
     $controller->set('fid', $this->_fid);
     $controller->setEmbedded(TRUE);
     $controller->process();
     $controller->run();
     $this->browse();
     if ($action & CRM_Core_Action::DELETE) {
         // add breadcrumb
         $url = CRM_Utils_System::url('civicrm/admin/price/field/option', 'reset=1');
         CRM_Utils_System::appendBreadCrumb(ts('Price Option'), $url);
         $this->assign('usedPriceSetTitle', CRM_Price_BAO_FieldValue::getOptionLabel($oid));
         $this->assign('usedBy', $usedBy);
         $comps = array("Event" => "civicrm_event", "Contribution" => "civicrm_contribution_page");
         $priceSetContexts = array();
         foreach ($comps as $name => $table) {
             if (array_key_exists($table, $usedBy)) {
                 $priceSetContexts[] = $name;
             }
         }
         $this->assign('contexts', $priceSetContexts);
     }
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:44,代码来源:Option.php

示例4: getStatusMsg

 /**
  * Function to build status message while
  * enabling/ disabling various objects
  */
 static function getStatusMsg()
 {
     $recordID = CRM_Utils_Type::escape($_POST['recordID'], 'Integer');
     $recordBAO = CRM_Utils_Type::escape($_POST['recordBAO'], 'String');
     $op = CRM_Utils_Type::escape($_POST['op'], 'String');
     $show = NULL;
     if ($op == 'disable-enable') {
         $status = ts('Are you sure you want to enable this record?');
     } else {
         switch ($recordBAO) {
             case 'CRM_Core_BAO_UFGroup':
                 require_once str_replace('_', DIRECTORY_SEPARATOR, $recordBAO) . '.php';
                 $method = 'getUFJoinRecord';
                 $result = array($recordBAO, $method);
                 $ufJoin = call_user_func_array($result, array($recordID, TRUE));
                 if (!empty($ufJoin)) {
                     $status = ts('This profile is currently used for %1.', array(1 => implode(', ', $ufJoin))) . ' <br/><br/>' . ts('If you disable the profile - it will be removed from these forms and/or modules. Do you want to continue?');
                 } else {
                     $status = ts('Are you sure you want to disable this profile?');
                 }
                 break;
             case 'CRM_Price_BAO_Set':
                 require_once str_replace('_', DIRECTORY_SEPARATOR, $recordBAO) . '.php';
                 $usedBy = CRM_Price_BAO_Set::getUsedBy($recordID);
                 $priceSet = CRM_Price_BAO_Set::getTitle($recordID);
                 if (!CRM_Utils_System::isNull($usedBy)) {
                     $template = CRM_Core_Smarty::singleton();
                     $template->assign('usedBy', $usedBy);
                     $comps = array('Event' => 'civicrm_event', 'Contribution' => 'civicrm_contribution_page');
                     $contexts = array();
                     foreach ($comps as $name => $table) {
                         if (array_key_exists($table, $usedBy)) {
                             $contexts[] = $name;
                         }
                     }
                     $template->assign('contexts', $contexts);
                     $show = 'noButton';
                     $table = $template->fetch('CRM/Price/Page/table.tpl');
                     $status = ts('Unable to disable the \'%1\' price set - it is currently in use by one or more active events, contribution pages or contributions.', array(1 => $priceSet)) . "<br/> {$table}";
                 } else {
                     $status = ts('Are you sure you want to disable \'%1\' Price Set?', array(1 => $priceSet));
                 }
                 break;
             case 'CRM_Event_BAO_Event':
                 $status = ts('Are you sure you want to disable this Event?');
                 break;
             case 'CRM_Core_BAO_UFField':
                 $status = ts('Are you sure you want to disable this CiviCRM Profile field?');
                 break;
             case 'CRM_Contribute_BAO_ManagePremiums':
                 $status = ts('Are you sure you want to disable this premium? This action will remove the premium from any contribution pages that currently offer it. However it will not delete the premium record - so you can re-enable it and add it back to your contribution page(s) at a later time.');
                 break;
             case 'CRM_Contact_BAO_RelationshipType':
                 $status = ts('Are you sure you want to disable this relationship type?') . '<br/><br/>' . ts('Users will no longer be able to select this value when adding or editing relationships between contacts.');
                 break;
             case 'CRM_Contribute_BAO_ContributionType':
                 $status = ts('Are you sure you want to disable this contribution type?');
                 break;
             case 'CRM_Core_BAO_PaymentProcessor':
                 $status = ts('Are you sure you want to disable this payment processor?') . ' <br/><br/>' . ts('Users will no longer be able to select this value when adding or editing transaction pages.');
                 break;
             case 'CRM_Core_BAO_PaymentProcessorType':
                 $status = ts('Are you sure you want to disable this payment processor type?');
                 break;
             case 'CRM_Core_BAO_LocationType':
                 $status = ts('Are you sure you want to disable this location type?') . ' <br/><br/>' . ts('Users will no longer be able to select this value when adding or editing contact locations.');
                 break;
             case 'CRM_Event_BAO_ParticipantStatusType':
                 $status = ts('Are you sure you want to disable this Participant Status?') . '<br/><br/> ' . ts('Users will no longer be able to select this value when adding or editing Participant Status.');
                 break;
             case 'CRM_Mailing_BAO_Component':
                 $status = ts('Are you sure you want to disable this component?');
                 break;
             case 'CRM_Core_BAO_CustomField':
                 $status = ts('Are you sure you want to disable this custom data field?');
                 break;
             case 'CRM_Core_BAO_CustomGroup':
                 $status = ts('Are you sure you want to disable this custom data group? Any profile fields that are linked to custom fields of this group will be disabled.');
                 break;
             case 'CRM_Core_BAO_MessageTemplates':
                 $status = ts('Are you sure you want to disable this message tempate?');
                 break;
             case 'CRM_ACL_BAO_ACL':
                 $status = ts('Are you sure you want to disable this ACL?');
                 break;
             case 'CRM_ACL_BAO_EntityRole':
                 $status = ts('Are you sure you want to disable this ACL Role Assignment?');
                 break;
             case 'CRM_Member_BAO_MembershipType':
                 $status = ts('Are you sure you want to disable this membership type?');
                 break;
             case 'CRM_Member_BAO_MembershipStatus':
                 $status = ts('Are you sure you want to disable this membership status rule?');
                 break;
             case 'CRM_Price_BAO_Field':
                 $status = ts('Are you sure you want to disable this price field?');
//.........这里部分代码省略.........
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:AJAX.php

示例5: buildQuickForm

 /**
  * Function to actually build the form
  * 
  * @param null
  * 
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     $this->applyFilter('__ALL__', 'trim');
     $this->assign('sid', $this->_sid);
     // title
     $this->add('text', 'title', ts('Set Name'), CRM_Core_DAO::getAttribute('CRM_Price_DAO_Set', 'title'), true);
     $this->addRule('title', ts('Name already exists in Database.'), 'objectExists', array('CRM_Price_DAO_Set', $this->_sid, 'title'));
     $priceSetUsedTables = $extends = array();
     if ($this->_action == CRM_Core_Action::UPDATE && $this->_sid) {
         $priceSetUsedTables = CRM_Price_BAO_Set::getUsedBy($this->_sid, true);
     }
     require_once 'CRM/Core/Config.php';
     require_once 'CRM/Core/Component.php';
     $config = CRM_Core_Config::singleton();
     $components = array('CiviEvent' => array('title' => ts('Event'), 'extend' => CRM_Core_Component::getComponentID('CiviEvent'), 'tables' => array('civicrm_event', 'civicrm_participant')), 'CiviContribute' => array('title' => ts('Contribution'), 'extend' => CRM_Core_Component::getComponentID('CiviContribute'), 'tables' => array('civicrm_contribution', 'civicrm_contribution_page')));
     foreach ($components as $compName => $compValues) {
         // take only enabled components.
         if (!in_array($compName, $config->enableComponents)) {
             continue;
         }
         $option = HTML_QuickForm::createElement('checkbox', $compValues['extend'], null, $compValues['title']);
         //if price set is used than freeze it.
         if (!empty($priceSetUsedTables)) {
             foreach ($compValues['tables'] as $table) {
                 if (in_array($table, $priceSetUsedTables)) {
                     $option->freeze();
                     break;
                 }
             }
         }
         $extends[] = $option;
     }
     if (CRM_Utils_System::isNull($extends)) {
         $this->assign('extends', false);
     } else {
         $this->assign('extends', true);
     }
     $this->addGroup($extends, 'extends', ts('Used For'), '&nbsp;', true);
     $this->addRule('extends', ts('%1 is a required field.', array(1 => ts('Used For'))), 'required');
     // help text
     $this->add('textarea', 'help_pre', ts('Pre-form Help'), CRM_Core_DAO::getAttribute('CRM_Price_DAO_Set', 'help_pre'));
     $this->add('textarea', 'help_post', ts('Post-form Help'), CRM_Core_DAO::getAttribute('CRM_Price_DAO_Set', 'help_post'));
     // is this set active ?
     $this->addElement('checkbox', 'is_active', ts('Is this Price Set active?'));
     $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
     $this->addFormRule(array('CRM_Price_Form_Set', 'formRule'));
     // views are implemented as frozen form
     if ($this->_action & CRM_Core_Action::VIEW) {
         $this->freeze();
         //$this->addElement('button', 'done', ts('Done'), array('onclick' => "location.href='civicrm/admin/price?reset=1&action=browse'"));
     }
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:60,代码来源:Set.php

示例6: getStatusMsg

 /**
  * Function to build status message while 
  * enabling/ disabling various objects
  */
 static function getStatusMsg(&$config)
 {
     $recordID = CRM_Utils_Type::escape($_POST['recordID'], 'Integer');
     $recordBAO = CRM_Utils_Type::escape($_POST['recordBAO'], 'String');
     $op = CRM_Utils_Type::escape($_POST['op'], 'String');
     $show = null;
     if ($op == 'disable-enable') {
         $status = ts('Are you sure you want to enable this record?');
     } else {
         switch ($recordBAO) {
             case 'CRM_Core_BAO_UFGroup':
                 require_once str_replace('_', DIRECTORY_SEPARATOR, $recordBAO) . ".php";
                 $method = 'getUFJoinRecord';
                 $result = array($recordBAO, $method);
                 $ufJoin = call_user_func_array($result, array($recordID, true));
                 if (!empty($ufJoin)) {
                     $status = ts('This profile is currently used for %1.', array(1 => implode(', ', $ufJoin))) . ' <br/><br/>' . ts('If you disable the profile - it will be removed from these forms and/or modules. Do you want to continue?');
                 } else {
                     $status = ts('Are you sure you want to disable this profile?');
                 }
                 break;
             case 'CRM_Price_BAO_Set':
                 require_once str_replace('_', DIRECTORY_SEPARATOR, $recordBAO) . ".php";
                 $usedBy = CRM_Price_BAO_Set::getUsedBy($recordID);
                 $priceSet = CRM_Price_BAO_Set::getTitle($recordID);
                 if (!CRM_Utils_System::isNull($usedBy)) {
                     $template =& CRM_Core_Smarty::singleton();
                     $template->assign('usedBy', $usedBy);
                     $comps = array("Event" => "civicrm_event", "Contribution" => "civicrm_contribution_page");
                     $contexts = array();
                     foreach ($comps as $name => $table) {
                         if (array_key_exists($table, $usedBy)) {
                             $contexts[] = $name;
                         }
                     }
                     $template->assign('contexts', $contexts);
                     $show = "noButton";
                     $table = $template->fetch('CRM/Price/Page/table.tpl');
                     $status = ts('Unable to disable the \'%1\' price set - it is currently in use by one or more active events, contribution pages or contributions.', array(1 => $priceSet)) . "<br/> {$table}";
                 } else {
                     $status = ts('Are you sure you want to disable \'%1\' Price Set?', array(1 => $priceSet));
                 }
                 break;
             case 'CRM_Event_BAO_Event':
                 $status = ts('Are you sure you want to disable this Event?');
                 break;
             case 'CRM_Core_BAO_UFField':
                 $status = ts('Are you sure you want to disable this CiviCRM Profile field?');
                 break;
             case 'CRM_Contribute_BAO_ManagePremiums':
                 $status = ts('Are you sure you want to disable this premium? This action will remove the premium from any contribution pages that currently offer it. However it will not delete the premium record - so you can re-enable it and add it back to your contribution page(s) at a later time.');
                 break;
             case 'CRM_Contact_BAO_RelationshipType':
                 $status = ts('Are you sure you want to disable this relationship type?') . '<br/><br/>' . ts('Users will no longer be able to select this value when adding or editing relationships between contacts.');
                 break;
             case 'CRM_Contribute_BAO_ContributionType':
                 $status = ts('Are you sure you want to disable this contribution type?');
                 break;
             case 'CRM_Core_BAO_PaymentProcessor':
                 $status = ts('Are you sure you want to disable this payment processor?') . ' <br/><br/>' . ts('Users will no longer be able to select this value when adding or editing transaction pages.');
                 break;
             case 'CRM_Core_BAO_PaymentProcessorType':
                 $status = ts('Are you sure you want to disable this payment processor type?');
                 break;
             case 'CRM_Core_BAO_LocationType':
                 $status = ts('Are you sure you want to disable this location type?') . ' <br/><br/>' . ts('Users will no longer be able to select this value when adding or editing contact locations.');
                 break;
             case 'CRM_Event_BAO_ParticipantStatusType':
                 $status = ts('Are you sure you want to disable this Participant Status?') . '<br/><br/> ' . ts('Users will no longer be able to select this value when adding or editing Participant Status.');
                 break;
             case 'CRM_Mailing_BAO_Component':
                 $status = ts('Are you sure you want to disable this component?');
                 break;
             case 'CRM_Core_BAO_CustomField':
                 $status = ts('Are you sure you want to disable this custom data field?');
                 break;
             case 'CRM_Core_BAO_CustomGroup':
                 $status = ts('Are you sure you want to disable this custom data group? Any profile fields that are linked to custom fields of this group will be disabled.');
                 break;
             case 'CRM_Core_BAO_MessageTemplates':
                 $status = ts('Are you sure you want to disable this message tempate?');
                 break;
             case 'CRM_ACL_BAO_ACL':
                 $status = ts('Are you sure you want to disable this ACL?');
                 break;
             case 'CRM_ACL_BAO_EntityRole':
                 $status = ts('Are you sure you want to disable this ACL Role Assignment?');
                 break;
             case 'CRM_Member_BAO_MembershipType':
                 $status = ts('Are you sure you want to disable this membership type?');
                 break;
             case 'CRM_Member_BAO_MembershipStatus':
                 $status = ts('Are you sure you want to disable this membership status rule?');
                 break;
             case 'CRM_Price_BAO_Field':
                 $status = ts('Are you sure you want to disable this price field?');
//.........这里部分代码省略.........
开发者ID:bhirsch,项目名称:voipdev,代码行数:101,代码来源:AJAX.php

示例7: run

 /**
  * Run the page.
  *
  * This method is called after the page is created. It checks for the  
  * type of action and executes that action. 
  * 
  * @param null
  * 
  * @return void
  * @access public
  */
 function run()
 {
     require_once 'CRM/Price/BAO/Set.php';
     // get the group id
     $this->_sid = CRM_Utils_Request::retrieve('sid', 'Positive', $this);
     $fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this, false, 0);
     $action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'browse');
     // default to 'browse'
     if ($this->_sid) {
         require_once 'CRM/Price/BAO/Set.php';
         CRM_Price_BAO_Set::checkPermission($this->_sid);
     }
     if ($action & CRM_Core_Action::DELETE) {
         require_once 'CRM/Price/BAO/Set.php';
         $usedBy =& CRM_Price_BAO_Set::getUsedBy($this->_sid);
         if (empty($usedBy)) {
             // prompt to delete
             $session =& CRM_Core_Session::singleton();
             $session->pushUserContext(CRM_Utils_System::url('civicrm/admin/price/field', 'reset=1&action=browse&sid=' . $this->_sid));
             $controller =& new CRM_Core_Controller_Simple('CRM_Price_Form_DeleteField', "Delete Price Field", '');
             $controller->set('fid', $fid);
             $controller->setEmbedded(true);
             $controller->process();
             $controller->run();
         } else {
             // add breadcrumb
             require_once 'CRM/Price/BAO/Field.php';
             $url = CRM_Utils_System::url('civicrm/admin/price/field', 'reset=1');
             CRM_Utils_System::appendBreadCrumb(ts('Price'), $url);
             $this->assign('usedPriceSetTitle', CRM_Price_BAO_Field::getTitle($fid));
             $this->assign('usedBy', $usedBy);
             $comps = array("Event" => "civicrm_event", "Contribution" => "civicrm_contribution_page");
             $priceSetContexts = array();
             foreach ($comps as $name => $table) {
                 if (array_key_exists($table, $usedBy)) {
                     $priceSetContexts[] = $name;
                 }
             }
             $this->assign('contexts', $priceSetContexts);
         }
     }
     if ($this->_sid) {
         $groupTitle = CRM_Price_BAO_Set::getTitle($this->_sid);
         $this->assign('sid', $this->_sid);
         $this->assign('groupTitle', $groupTitle);
         CRM_Utils_System::setTitle(ts('%1 - Price Fields', array(1 => $groupTitle)));
     }
     // assign vars to templates
     $this->assign('action', $action);
     // what action to take ?
     if ($action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) {
         $this->edit($action);
         // no browse for edit/update/view
     } else {
         if ($action & CRM_Core_Action::PREVIEW) {
             $this->preview($fid);
         } else {
             require_once 'CRM/Price/BAO/Field.php';
             $this->browse();
         }
     }
     // Call the parents run method
     parent::run();
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:75,代码来源:Field.php

示例8: edit

 /**
  * edit custom Option.
  *
  * editing would involved modifying existing fields + adding data to new fields.
  *
  * @param string  $action   the action to be invoked
  * 
  * @return void
  * @access public
  */
 function edit($action)
 {
     $oid = CRM_Utils_Request::retrieve('oid', 'Positive', $this, false, 0);
     $params = array();
     if ($oid) {
         $params['oid'] = $oid;
         require_once 'CRM/Price/BAO/Set.php';
         $sid = CRM_Price_BAO_Set::getSetId($params);
         require_once 'CRM/Price/BAO/Set.php';
         $usedBy =& CRM_Price_BAO_Set::getUsedBy($sid);
     }
     // set the userContext stack
     $session =& CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url('civicrm/admin/price/field/option', "reset=1&action=browse&fid={$this->_fid}&sid={$this->_sid}"));
     $controller =& new CRM_Core_Controller_Simple('CRM_Price_Form_Option', ts('Price Field Option'), $action);
     $controller->set('fid', $this->_fid);
     $controller->setEmbedded(true);
     $controller->process();
     $controller->run();
     $this->browse();
     if ($action & CRM_Core_Action::DELETE) {
         // add breadcrumb
         require_once 'CRM/Core/BAO/OptionValue.php';
         $url = CRM_Utils_System::url('civicrm/admin/price/field/option', 'reset=1');
         CRM_Utils_System::appendBreadCrumb(ts('Price Option'), $url);
         $this->assign('usedPriceSetTitle', CRM_Core_BAO_OptionValue::getTitle($oid));
         $this->assign('usedBy', $usedBy);
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:39,代码来源:Option.php

示例9: run

 /**
  * Run the page.
  *
  * This method is called after the page is created. It checks for the
  * type of action and executes that action.
  *
  * @param null
  *
  * @return void
  * @access public
  */
 function run()
 {
     // get the group id
     $this->_sid = CRM_Utils_Request::retrieve('sid', 'Positive', $this);
     $fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this, FALSE, 0);
     $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
     if ($this->_sid) {
         $usedBy = CRM_Price_BAO_Set::getUsedBy($this->_sid);
         $this->assign('usedBy', $usedBy);
         $this->_isSetReserved = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', $this->_sid, 'is_reserved');
         $this->assign('isReserved', $this->_isSetReserved);
         CRM_Price_BAO_Set::checkPermission($this->_sid);
         $comps = array('Event' => 'civicrm_event', 'Contribution' => 'civicrm_contribution_page');
         $priceSetContexts = array();
         foreach ($comps as $name => $table) {
             if (array_key_exists($table, $usedBy)) {
                 $priceSetContexts[] = $name;
             }
         }
         $this->assign('contexts', $priceSetContexts);
     }
     if ($action & CRM_Core_Action::DELETE && !$this->_isSetReserved) {
         if (empty($usedBy)) {
             // prompt to delete
             $session = CRM_Core_Session::singleton();
             $session->pushUserContext(CRM_Utils_System::url('civicrm/admin/price/field', 'reset=1&action=browse&sid=' . $this->_sid));
             $controller = new CRM_Core_Controller_Simple('CRM_Price_Form_DeleteField', 'Delete Price Field', '');
             $controller->set('fid', $fid);
             $controller->setEmbedded(TRUE);
             $controller->process();
             $controller->run();
         } else {
             // add breadcrumb
             $url = CRM_Utils_System::url('civicrm/admin/price/field', 'reset=1');
             CRM_Utils_System::appendBreadCrumb(ts('Price'), $url);
             $this->assign('usedPriceSetTitle', CRM_Price_BAO_Field::getTitle($fid));
         }
     }
     if ($this->_sid) {
         $groupTitle = CRM_Price_BAO_Set::getTitle($this->_sid);
         $this->assign('sid', $this->_sid);
         $this->assign('groupTitle', $groupTitle);
         CRM_Utils_System::setTitle(ts('%1 - Price Fields', array(1 => $groupTitle)));
     }
     // assign vars to templates
     $this->assign('action', $action);
     // what action to take ?
     if ($action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD) && !$this->_isSetReserved) {
         // no browse for edit/update/view
         $this->edit($action);
     } elseif ($action & CRM_Core_Action::PREVIEW) {
         $this->preview($fid);
     } else {
         $this->browse();
     }
     // Call the parents run method
     return parent::run();
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:69,代码来源:Field.php

示例10: buildQuickForm

 /**
  * Function to actually build the form
  * 
  * @param null
  * 
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     $this->applyFilter('__ALL__', 'trim');
     $this->assign('sid', $this->_sid);
     // title
     $this->add('text', 'title', ts('Set Name'), CRM_Core_DAO::getAttribute('CRM_Price_DAO_Set', 'title'), true);
     $this->addRule('title', ts('Name already exists in Database.'), 'objectExists', array('CRM_Price_DAO_Set', $this->_sid, 'title'));
     $components = array('contribution', 'event');
     $tables = array();
     if ($this->_action == CRM_Core_Action::UPDATE && $this->_sid) {
         $tables = CRM_Price_BAO_Set::getUsedBy($this->_sid, true);
     }
     require_once 'CRM/Core/Config.php';
     $config =& CRM_Core_Config::singleton();
     $enabledComponents = $config->enableComponents;
     // used for component
     foreach ($components as $i => $component) {
         if ($enabledComponents && in_array('Civi' . ucfirst($component), $enabledComponents)) {
             $extends[$i] = HTML_QuickForm::createElement('checkbox', ucfirst($component), null, ucfirst($component));
             if (!empty($tables) && (in_array('civicrm_' . $component, $tables) || in_array('civicrm_' . $component . '_page', $tables))) {
                 $extends[$i]->_flagFrozen = true;
             }
         }
     }
     $this->addGroup($extends, 'extends', ts('Used For'), '&nbsp;', true);
     $this->addRule('extends', ts('%1 is a required field.', array(1 => ts('Used For'))), 'required');
     // help text
     $this->add('textarea', 'help_pre', ts('Pre-form Help'), CRM_Core_DAO::getAttribute('CRM_Price_DAO_Set', 'help_pre'));
     $this->add('textarea', 'help_post', ts('Post-form Help'), CRM_Core_DAO::getAttribute('CRM_Price_DAO_Set', 'help_post'));
     // is this set active ?
     $this->addElement('checkbox', 'is_active', ts('Is this Price Set active?'));
     $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
     // views are implemented as frozen form
     if ($this->_action & CRM_Core_Action::VIEW) {
         $this->freeze();
         //$this->addElement('button', 'done', ts('Done'), array('onclick' => "location.href='civicrm/admin/price?reset=1&action=browse'"));
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:46,代码来源:Set.php


注:本文中的CRM_Price_BAO_Set::getUsedBy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。