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


PHP Company::isOwner方法代码示例

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


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

示例1: delete

 /**
  * Delete Company
  *
  * @param void
  * @return null
  */
 function delete()
 {
     if ($this->active_company->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (!$this->active_company->canDelete($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN, null, true, $this->request->isApiCall());
     }
     // if
     if ($this->active_company->isNew() || $this->active_company->isOwner()) {
         $this->httpError(HTTP_ERR_NOT_FOUND, null, true, $this->request->isApiCall());
     }
     // if
     if ($this->request->isSubmitted()) {
         $old_name = $this->active_company->getName();
         $delete = $this->active_company->delete();
         if ($delete && !is_error($delete)) {
             if ($this->request->isApiCall()) {
                 $this->httpOk();
             } else {
                 flash_success("Company ':name' has been deleted", array('name' => $old_name));
                 $this->redirectTo('people');
             }
             // if
         } else {
             if ($this->request->isApiCall()) {
                 $this->httpError(HTTP_ERR_OPERATION_FAILED, null, true, $this->request->isApiCall());
             } else {
                 flash_error("Failed to delete :name", array('name' => $old_name));
                 $this->redirectTo('people');
             }
             // if
         }
         // if
     } else {
         $this->httpError(HTTP_ERR_BAD_REQUEST, null, true, $this->request->isApiCall());
     }
     // if
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:46,代码来源:CompaniesController.class.php

示例2: getProjectsByCompany

 /**
  * Return all projects that this company is member of
  *
  * @access public
  * @param Company $company
  * @param string $additional_conditions Additional SQL conditions
  * @return array
  */
 static function getProjectsByCompany(Company $company, $additional_conditions = null)
 {
     if ($company->isOwner()) {
         return Projects::getAll();
     }
     $projects_table = Projects::instance()->getTableName(true);
     $project_companies_table = ProjectCompanies::instance()->getTableName(true);
     $projects = array();
     $sql = "SELECT {$projects_table}.* FROM {$projects_table}, {$project_companies_table} WHERE ({$projects_table}.`id` = {$project_companies_table}.`project_id` AND {$project_companies_table}.`company_id` = " . DB::escape($company->getId()) . ')';
     if (trim($additional_conditions) != '') {
         $sql .= " AND ({$additional_conditions})";
     }
     $rows = DB::executeAll($sql);
     if (is_array($rows)) {
         foreach ($rows as $row) {
             $projects[] = Projects::instance()->loadFromRow($row);
         }
         // foreach
     }
     // if
     return count($projects) ? $projects : null;
 }
开发者ID:469306621,项目名称:Languages,代码行数:30,代码来源:ProjectCompanies.class.php

示例3: canSeeCompany

    /**
    * Returns true if this user can see $company. Members of owener company and
    * coworkers are visible without project check! Also, members of owner company
    * can see all clients without any prior check!
    *
    * @param Company $company
    * @return boolean
    */
    function canSeeCompany(Company $company) {
      if ($this->isMemberOfOwnerCompany()) {
        return true;
      } // if
            
      if ($company->isOwner()) {
        $this->visible_companies[$company->getId()] = true;
        return true;
      } // if

      if (isset($this->visible_companies[$company->getId()])) {
        return $this->visible_companies[$company->getId()];
      } // if

      if ($this->getCompanyId() == $company->getId()) {
        $this->visible_companies[$company->getId()] = true;
        return true;
      } // if
      
      // Lets company projects for company of this user and for $company and 
      // compare if we have projects where both companies work together
      $projects_1 = DB::executeAll("SELECT `project_id` FROM " . ProjectCompanies::instance()->getTableName(true) . " WHERE `company_id` = ?", $this->getCompanyId());
      $projects_2 = DB::executeAll("SELECT `project_id` FROM " . ProjectCompanies::instance()->getTableName(true) . " WHERE `company_id` = ?", $company->getId());
      
      if (!is_array($projects_1) || !is_array($projects_2)) {
        $this->visible_companies[$company->getId()] = false;
        return false;
      } // if
      
      foreach ($projects_1 as $project_id) {
        if (in_array($project_id, $projects_2)) {
          $this->visible_companies[$company->getId()] = true;
          return true;
        } // if
      } // foreach
      
      $this->visible_companies[$company->getId()] = false;
      return false;
    } // canSeeCompany
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:47,代码来源:User.class.php

示例4: canRemoveCompanyFromProject

 /**
  * Check if specific user can remove company from project
  *
  * @access public
  * @param User $user
  * @param Company $remove_company Remove this company
  * @return boolean
  */
 function canRemoveCompanyFromProject(User $user, Company $remove_company)
 {
     if ($remove_company->isOwner()) {
         return false;
     }
     return $user->isAccountOwner() || $user->isAdministrator();
 }
开发者ID:swenson,项目名称:projectpier,代码行数:15,代码来源:Project.class.php

示例5: canRemoveCompanyFromProject

 /**
 * Check if specific user can remove company from project
 *
 * @access public
 * @param User $user
 * @param Company $remove_company Remove this company
 * @return boolean
 */
 function canRemoveCompanyFromProject(User $user, Company $remove_company) {
   if ($remove_company->isOwner()) {
     return false;
   }
   return ($this->getCreatedById() == $user->getId()) || $user->isAccountOwner() || $user->isAdministrator();
 } // canRemoveCompanyFromProject
开发者ID:rjv,项目名称:Project-Pier,代码行数:14,代码来源:Project.class.php

示例6: canRemoveCompanyFromProject

 /**
  * Check if specific user can remove company from project
  *
  * @access public
  * @param User $user
  * @param Company $remove_company Remove this company
  * @return boolean
  */
 function canRemoveCompanyFromProject(User $user, Company $remove_company)
 {
     if ($remove_company->isOwner()) {
         return false;
     }
     return $user->isAccountOwner() || can_manage_workspaces(logged_user()) || can_manage_security(logged_user());
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:15,代码来源:Project.class.php

示例7: canSeeCompany

 /**
  * Returns true if this user can see $company. Members of owener company and
  * coworkers are visible without project check! Also, members of owner company
  * can see all clients without any prior check!
  *
  * @param Company $company
  * @return boolean
  */
 function canSeeCompany(Company $company)
 {
     if ($this->isMemberOfOwnerCompany()) {
         return true;
     }
     // if
     if (isset($this->visible_companies[$company->getId()])) {
         return $this->visible_companies[$company->getId()];
     }
     // if
     if ($company->isOwner()) {
         $this->visible_companies[$company->getId()] = true;
         return true;
     }
     // if
     if ($this->getCompanyId() == $company->getId()) {
         $this->visible_companies[$company->getId()] = true;
         return true;
     }
     // if
     if ($company->canView($this)) {
         $this->visible_companies[$company->getId()] = true;
         return true;
     }
     $this->visible_companies[$company->getId()] = false;
     return false;
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:35,代码来源:User.class.php

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