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


PHP Company::canAdd方法代码示例

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


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

示例1: smarty_function_select_company

/**
 * Render select company box
 * 
 * Parameters:
 * 
 * - value - Value of selected company
 * - optional - Is value of this field optional or not
 * - exclude - Array of company ID-s that will be excluded
 * - can_create_new - Should this select box offer option to create a new 
 *   company from within the list
 * 
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_select_company($params, &$smarty)
{
    static $ids = array();
    $companies = Companies::getIdNameMap(array_var($params, 'companies'));
    $value = array_var($params, 'value', null, true);
    $id = array_var($params, 'id', null, true);
    if (empty($id)) {
        $counter = 1;
        do {
            $id = "select_company_dropdown_{$counter}";
            $counter++;
        } while (in_array($id, $ids));
    }
    // if
    $ids[] = $id;
    $params['id'] = $id;
    $optional = array_var($params, 'optional', false, true);
    $exclude = array_var($params, 'exclude', array(), true);
    if (!is_array($exclude)) {
        $exclude = array();
    }
    // if
    $can_create_new = array_var($params, 'can_create_new', true, true);
    if ($optional) {
        $options = array(option_tag(lang('-- None --'), ''), option_tag('', ''));
    } else {
        $options = array();
    }
    // if
    foreach ($companies as $company_id => $company_name) {
        if (in_array($company_id, $exclude)) {
            continue;
        }
        // if
        $option_attributes = array('class' => 'object_option');
        if ($value == $company_id) {
            $option_attributes['selected'] = true;
        }
        // if
        $options[] = option_tag($company_name, $company_id, $option_attributes);
    }
    // if
    if ($can_create_new) {
        $logged_user = get_logged_user();
        if (instance_of($logged_user, 'User') && Company::canAdd($logged_user)) {
            $params['add_object_url'] = assemble_url('people_companies_quick_add');
            $params['object_name'] = 'company';
            $params['add_object_message'] = lang('Please insert new company name');
            $options[] = option_tag('', '');
            $options[] = option_tag(lang('New Company...'), '', array('class' => 'new_object_option'));
        }
        // if
    }
    // if
    return select_box($options, $params) . '<script type="text/javascript">$("#' . $id . '").new_object_from_select();</script>';
}
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:71,代码来源:function.select_company.php

示例2: __construct

 /**
  * Constructor
  *
  * @param Request $request
  * @return PeopleController
  */
 function __construct($request)
 {
     parent::__construct($request);
     $this->wireframe->addBreadCrumb(lang('People'), assemble_url('people'));
     $this->wireframe->current_menu_item = 'people';
     if (Company::canAdd($this->logged_user)) {
         $this->wireframe->addPageAction(lang('New Company'), assemble_url('people_companies_add'));
     }
     // if
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:16,代码来源:PeopleController.class.php

示例3: quick_add

 /**
  * Quick add company
  *
  * @param void
  * @return null
  */
 function quick_add()
 {
     if ($this->request->isSubmitted() && $this->request->isAsyncCall()) {
         if (!Company::canAdd($this->logged_user)) {
             $this->httpError(HTTP_ERR_FORBIDDEN, null, true, $this->request->isApiCall());
         }
         // if
         $company = new Company();
         $company->setAttributes($this->request->post('company'));
         $save = $company->save();
         if ($save && !is_error($save)) {
             print $company->getId();
             die;
         } else {
             $this->serveData($save);
         }
         // if
     } else {
         $this->httpError(HTTP_ERR_BAD_REQUEST);
     }
     // if
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:28,代码来源:CompaniesController.class.php

示例4: add_client

 /**
  * Add client
  *
  * @param void
  * @return null
  */
 function add_client()
 {
     if (logged_user()->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $this->setTemplate('add_company');
     if (!Company::canAdd(logged_user(), active_or_personal_project())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     $company = new Company();
     $company_data = array_var($_POST, 'company');
     if (!is_array($company_data)) {
         $company_data = array('timezone' => logged_user()->getTimezone());
         // array
     }
     // if
     tpl_assign('company', $company);
     tpl_assign('company_data', $company_data);
     if (is_array(array_var($_POST, 'company'))) {
         $company->setFromAttributes($company_data);
         $company->setClientOfId(owner_company()->getId());
         try {
             DB::beginWork();
             $company->save();
             $company->setTagsFromCSV(array_var($company_data, 'tags'));
             $object_controller = new ObjectController();
             $object_controller->add_to_workspaces($company, !can_manage_contacts(logged_user()));
             $object_controller->link_to_new_object($company);
             $object_controller->add_subscribers($company);
             $object_controller->add_custom_properties($company);
             ApplicationLogs::createLog($company, $company->getWorkspaces(), ApplicationLogs::ACTION_ADD);
             //				ApplicationLogs::createLog($company, null, ApplicationLogs::ACTION_ADD);
             DB::commit();
             flash_success(lang('success add client', $company->getName()));
             evt_add("company added", array("id" => $company->getId(), "name" => $company->getName()));
             ajx_current("back");
         } catch (Exception $e) {
             DB::rollback();
             ajx_current("empty");
             flash_error($e->getMessage());
         }
         // try
     }
     // if
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:56,代码来源:CompanyController.class.php

示例5: unset

 function import_from_csv_file()
 {
     if (logged_user()->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     @set_time_limit(0);
     ini_set('auto_detect_line_endings', '1');
     if (isset($_GET['from_menu']) && $_GET['from_menu'] == 1) {
         unset($_SESSION['history_back']);
     }
     if (isset($_SESSION['history_back'])) {
         unset($_SESSION['history_back']);
         ajx_current("start");
     } else {
         if (!Contact::canAdd(logged_user(), active_or_personal_project())) {
             flash_error(lang('no access permissions'));
             ajx_current("empty");
             return;
         }
         // if
         $this->setTemplate('csv_import');
         $type = array_var($_GET, 'type', array_var($_SESSION, 'import_type', 'contact'));
         //type of import (contact - company)
         if (!isset($_SESSION['import_type']) || $type != $_SESSION['import_type'] && $type != '') {
             $_SESSION['import_type'] = $type;
         }
         tpl_assign('import_type', $type);
         $filedata = array_var($_FILES, 'csv_file');
         if (is_array($filedata) && !is_array(array_var($_POST, 'select_contact'))) {
             $filename = $filedata['tmp_name'] . '.csv';
             copy($filedata['tmp_name'], $filename);
             $first_record_has_names = array_var($_POST, 'first_record_has_names', false);
             $delimiter = array_var($_POST, 'delimiter', '');
             if ($delimiter == '') {
                 $delimiter = $this->searchForDelimiter($filename);
             }
             $_SESSION['delimiter'] = $delimiter;
             $_SESSION['csv_import_filename'] = $filename;
             $_SESSION['first_record_has_names'] = $first_record_has_names;
             $titles = $this->read_csv_file($filename, $delimiter, true);
             tpl_assign('titles', $titles);
         }
         if (array_var($_GET, 'calling_back', false)) {
             $filename = $_SESSION['csv_import_filename'];
             $delimiter = $_SESSION['delimiter'];
             $first_record_has_names = $_SESSION['first_record_has_names'];
             $titles = $this->read_csv_file($filename, $delimiter, true);
             unset($_GET['calling_back']);
             tpl_assign('titles', $titles);
         }
         if (is_array(array_var($_POST, 'select_contact')) || is_array(array_var($_POST, 'select_company'))) {
             $type = $_SESSION['import_type'];
             $filename = $_SESSION['csv_import_filename'];
             $delimiter = $_SESSION['delimiter'];
             $first_record_has_names = $_SESSION['first_record_has_names'];
             $registers = $this->read_csv_file($filename, $delimiter);
             $import_result = array('import_ok' => array(), 'import_fail' => array());
             $i = $first_record_has_names ? 1 : 0;
             while ($i < count($registers)) {
                 try {
                     DB::beginWork();
                     if ($type == 'contact') {
                         $contact_data = $this->buildContactData(array_var($_POST, 'select_contact'), array_var($_POST, 'check_contact'), $registers[$i]);
                         $contact_data['import_status'] = '(' . lang('updated') . ')';
                         $fname = mysql_real_escape_string(array_var($contact_data, "firstname"));
                         $lname = mysql_real_escape_string(array_var($contact_data, "lastname"));
                         $email_cond = array_var($contact_data, "email") != '' ? " OR email = '" . array_var($contact_data, "email") . "'" : "";
                         $contact = Contacts::findOne(array("conditions" => "firstname = '" . $fname . "' AND lastname = '" . $lname . "' {$email_cond}"));
                         $log_action = ApplicationLogs::ACTION_EDIT;
                         if (!$contact) {
                             $contact = new Contact();
                             $contact_data['import_status'] = '(' . lang('new') . ')';
                             $log_action = ApplicationLogs::ACTION_ADD;
                             $can_import = active_project() != null ? $contact->canAdd(logged_user(), active_project()) : can_manage_contacts(logged_user());
                         } else {
                             $can_import = $contact->canEdit(logged_user());
                         }
                         if ($can_import) {
                             $comp_name = mysql_real_escape_string(array_var($contact_data, "company_id"));
                             if ($comp_name != '') {
                                 $company = Companies::findOne(array("conditions" => "name = '{$comp_name}'"));
                                 if ($company) {
                                     $contact_data['company_id'] = $company->getId();
                                 } else {
                                     $company_data = self::getCompanyDataFromContactData($contact_data);
                                     $company = new Company();
                                     $company->setFromAttributes($company_data);
                                     if ($company->isOwner()) {
                                         $company->setClientOfId(0);
                                     } else {
                                         $company->setClientOfId(owner_company()->getId());
                                     }
                                     $company->save();
                                     ApplicationLogs::createLog($company, null, ApplicationLogs::ACTION_ADD);
                                     $company->setTagsFromCSV(array_var($_POST, 'tags'));
                                     if (active_project() instanceof Project) {
                                         $company->addToWorkspace(active_project());
                                     }
//.........这里部分代码省略.........
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:101,代码来源:ContactController.class.php


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