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


PHP Contact::canAdd方法代码示例

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


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

示例1: add_company

	/**
	 * Add company
	 *
	 * @param void
	 * @return null
	 */
	function add_company() {
		if (logged_user()->isGuest()) {
			flash_error(lang('no access permissions'));
			ajx_current("empty");
			return;
		}
		$notAllowedMember = '';				
		if(!Contact::canAdd(logged_user(),active_context(),$notAllowedMember)) {
			if (str_starts_with($notAllowedMember, '-- req dim --')) flash_error(lang('must choose at least one member of', str_replace_first('-- req dim --', '', $notAllowedMember, $in)));
			else flash_error(lang('no context permissions to add',lang("contacts"), $notAllowedMember));
			ajx_current("empty");
			return;
		} // if
		
		$company = new Contact();
		$company->setIsCompany(1);
		$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->setObjectName();

	

			try {
				Contacts::validate($company_data); 
				DB::beginWork();
				$company->save();
				if($company_data['address'] != "")
				$company->addAddress($company_data['address'], $company_data['city'], $company_data['state'], $company_data['country'], $company_data['zipcode'], 'work', true);
				if($company_data['phone_number'] != "") $company->addPhone($company_data['phone_number'], 'work', true);
				if($company_data['fax_number'] != "") $company->addPhone($company_data['fax_number'], 'fax', true);
				if($company_data['homepage'] != "") $company->addWebpage($company_data['homepage'], 'work');
				if($company_data['email'] != "") $company->addEmail($company_data['email'], 'work' , true);
				
				$object_controller = new ObjectController();
				$object_controller->add_subscribers($company);

				$member_ids = json_decode(array_var($_POST, 'members'));
				if (!is_null($member_ids)) {
					$object_controller->add_to_members($company, $member_ids);
				}
				$object_controller->link_to_new_object($company);
				$object_controller->add_custom_properties($company);
				
				ApplicationLogs::createLog($company, ApplicationLogs::ACTION_ADD);

				DB::commit();

				flash_success(lang('success add client', $company->getObjectName()));
				evt_add("company added", array("id" => $company->getObjectId(), "name" => $company->getObjectName()));
				ajx_current("back");
			} catch(Exception $e) {
				DB::rollback();
				ajx_current("empty");
				flash_error($e->getMessage());
			} // try
		} // if
	} // add_company
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:74,代码来源:ContactController.class.php

示例2: canAddContact

 /**
  * Check if this user can add new contact to this company
  *
  * @access public
  * @param User $user
  * @return boolean
  */
 function canAddContact(User $user)
 {
     return Contact::canAdd($user, $this);
 }
开发者ID:bklein01,项目名称:Project-Pier,代码行数:11,代码来源:Company.class.php

示例3: getPersonLinkFromEmailAddress

 private static function getPersonLinkFromEmailAddress($email, $addr_name, $clean = true, $add_contact_link = true)
 {
     $name = $email;
     $url = "";
     $user = Users::getByEmail($email);
     if ($user instanceof User && $user->canSeeUser(logged_user())) {
         $name = $clean ? clean($user->getDisplayName()) : $user->getDisplayName();
         $url = $user->getCardUrl();
     } else {
         $contact = Contacts::getByEmail($email);
         if ($contact instanceof Contact && $contact->canView(logged_user())) {
             $name = $clean ? clean($contact->getDisplayName()) : $contact->getDisplayName();
             $url = $contact->getCardUrl();
         }
     }
     if ($url != "") {
         return '<a class="internalLink" href="' . $url . '" title="' . $email . '">' . $name . " &lt;{$email}&gt;</a>";
     } else {
         if (!(active_project() instanceof Project ? Contact::canAdd(logged_user(), active_project()) : can_manage_contacts(logged_user()))) {
             return $email;
         } else {
             $url = get_url('contact', 'add', array('ce' => $email));
             $to_show = $addr_name == '' ? $email : $addr_name . " &lt;{$email}&gt;";
             return $to_show . ($add_contact_link ? '&nbsp;<a class="internalLink link-ico ico-add" style="padding-left:12px;" href="' . $url . '" title="' . lang('add contact') . '">&nbsp;</a>' : '');
         }
     }
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:27,代码来源:MailUtilities.class.php

示例4: getPersonLinkFromEmailAddress

 private static function getPersonLinkFromEmailAddress($email, $addr_name, $clean = true, $add_contact_link = true)
 {
     $name = $email;
     $url = "";
     if (trim($email) == "") {
         return "";
     }
     if (!is_valid_email($email)) {
         return $email;
     }
     $contact = Contacts::getByEmail($email);
     if ($contact instanceof Contact && $contact->canView(logged_user())) {
         $name = $clean ? clean($contact->getObjectName()) : $contact->getObjectName();
         $url = $contact->getCardUrl();
     }
     if ($url != "") {
         return '<a class="internalLink" href="' . $url . '" title="' . $email . '">' . $name . " &lt;{$email}&gt;</a>";
     } else {
         $null = null;
         if (!Contact::canAdd(logged_user(), active_context(), $null)) {
             return $email;
         } else {
             if (trim($email) == "") {
                 return "";
             }
             $url = get_url('contact', 'add', array('ce' => $email));
             $to_show = $addr_name == '' ? $email : $addr_name . " &lt;{$email}&gt;";
             return $to_show . ($add_contact_link ? '&nbsp;<a class="internalLink link-ico ico-add" style="padding-left:12px;" href="' . $url . '" title="' . lang('add contact') . '">&nbsp;</a>' : '');
         }
     }
 }
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:31,代码来源:MailUtilities.class.php

示例5: set_page_title

<?php

// Set page title and set crumbs to index
set_page_title(lang('company card of', $company->getName()));
dashboard_tabbed_navigation();
if (logged_user()->isMemberOfOwnerCompany()) {
    dashboard_crumbs(array(array(lang('contacts'), get_url('dashboard', 'contacts')), array($company->getName())));
} else {
    dashboard_crumbs(array(array($company->getName())));
}
// if
if ($company->canEdit(logged_user())) {
    add_page_action(lang('edit company'), $company->getEditUrl());
    add_page_action(lang('edit company logo'), $company->getEditLogoUrl());
    if (!$company->isOwner()) {
        add_page_action(lang('update permissions'), $company->getUpdatePermissionsUrl());
    }
    // if
}
// if
if (Contact::canAdd(logged_user(), $company)) {
    add_page_action(lang('add contact'), $company->getAddContactUrl());
}
// if
add_stylesheet_to_page('dashboard/company_list.css');
$this->includeTemplate(get_template_path('company_card', 'company'));
开发者ID:bklein01,项目名称:Project-Pier,代码行数:26,代码来源:card.php

示例6: tpl_assign

        $image .= '</a>';
    }
    $image .= '</div>';
    tpl_assign("image", $image);
} else {
    if ($company->canEdit(logged_user())) {
        $image .= '<a class="internalLink" href="' . $company->getUpdatePictureUrl() . '" title="' . lang('edit picture') . '"><div id="2_iconDiv" class="coViewIconImage ico-large-contact"></div></a>';
        tpl_assign("image", $image);
    }
}
if (!$company->isTrashed()) {
    if ($company->canAddUser(logged_user())) {
        add_page_action(lang('add user'), $company->getAddUserUrl(), 'ico-add');
    }
    // if
    if (Contact::canAdd(logged_user(), $company->getMembers())) {
        add_page_action(lang('add contact'), $company->getAddContactUrl(), 'ico-add');
    }
    // if
    if ($company->canEdit(logged_user())) {
        add_page_action(lang('edit company'), $company->getEditUrl(), 'ico-edit', null, null, true);
        add_page_action(lang('change logo'), $company->getUpdatePictureUrl(), 'ico-picture', null, null, true);
        if (!$company->isOwnerCompany()) {
            if (!$company->isArchived()) {
                add_page_action(lang('archive'), "javascript:if(confirm(lang('confirm archive object'))) og.openLink('" . $company->getArchiveUrl() . "');", 'ico-archive-obj');
            } else {
                add_page_action(lang('unarchive'), "javascript:if(confirm(lang('confirm unarchive object'))) og.openLink('" . $company->getUnarchiveUrl() . "');", 'ico-unarchive-obj');
            }
        }
    }
    // if
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:31,代码来源:view_company.php

示例7: add

 /**
  * Add contact
  *
  * @access public
  * @param void
  * @return null
  */
 function add()
 {
     $this->setTemplate('add_contact');
     $company_id = get_id('company_id', null, 0);
     $company = Companies::findById($company_id);
     if (!Contact::canAdd(logged_user(), $company)) {
         flash_error(lang('no access permissions'));
         $this->redirectToReferer(get_url('dashboard', 'index'));
     }
     // if
     $contact = new Contact();
     $im_types = ImTypes::findAll(array('order' => '`id`'));
     $contact_data = array_var($_POST, 'contact');
     if (!is_array($contact_data)) {
         $contact_data = array('company_id' => $company_id);
         // array
     }
     // if
     $user_data = array_var($contact_data, 'user');
     if (!is_array($user_data)) {
         $user_data = array('password_generator' => 'random');
         // array
     }
     // if
     tpl_assign('contact', $contact);
     tpl_assign('company', $company);
     tpl_assign('contact_data', $contact_data);
     tpl_assign('user_data', $user_data);
     tpl_assign('im_types', $im_types);
     $avatar = array_var($_FILES, 'new_avatar');
     if (is_array($avatar) && isset($avatar['size']) && $avatar['size'] != 0) {
         try {
             if (!isset($avatar['name']) || !isset($avatar['type']) || !isset($avatar['size']) || !isset($avatar['tmp_name']) || !is_readable($avatar['tmp_name'])) {
                 throw new InvalidUploadError($avatar, lang('error upload file'));
             }
             // if
             $valid_types = array('image/jpg', 'image/jpeg', 'image/pjpeg', 'image/gif', 'image/png');
             $max_width = config_option('max_avatar_width', 50);
             $max_height = config_option('max_avatar_height', 50);
             if ($avatar['size']) {
                 if (!in_array($avatar['type'], $valid_types) || !($image = getimagesize($avatar['tmp_name']))) {
                     throw new InvalidUploadError($avatar, lang('invalid upload type', 'JPG, GIF, PNG'));
                 } elseif (!$contact->setAvatar($avatar['tmp_name'], $max_width, $max_height, false)) {
                     throw new Error($avatar, lang('error edit avatar'));
                     $contact->setAvatarFile('');
                 }
                 // if
             }
             // if
         } catch (Exception $e) {
             flash_error($e->getMessage());
         }
     } else {
         $contact->setAvatarFile('');
     }
     // if
     if (is_array(array_var($_POST, 'contact'))) {
         $contact->setFromAttributes($contact_data);
         try {
             // Company info
             if ($_POST['contact']['company']['what'] == 'existing') {
                 $company_id = $_POST['contact']['company_id'];
             } else {
                 $company = new Company();
                 $company->setName($_POST['contact']['company']['name']);
                 $company->setTimezone($_POST['contact']['company']['timezone']);
                 $company->setClientOfId(owner_company()->getId());
                 $company->save();
                 $company_id = $company->getId();
             }
             // if
             $contact->setCompanyId($company_id);
             $contact->setUserId(0);
             $contact->save();
             if (plugin_active('tags')) {
                 $contact->setTagsFromCSV(array_var($contact_data, 'tags'));
             }
             $contact->clearImValues();
             foreach ($im_types as $im_type) {
                 $value = trim(array_var($contact_data, 'im_' . $im_type->getId()));
                 if ($value != '') {
                     $contact_im_value = new ContactImValue();
                     $contact_im_value->setContactId($contact->getId());
                     $contact_im_value->setImTypeId($im_type->getId());
                     $contact_im_value->setValue($value);
                     $contact_im_value->setIsDefault(array_var($contact_data, 'default_im') == $im_type->getId());
                     $contact_im_value->save();
                 }
                 // if
             }
             // foreach
             ApplicationLogs::createLog($contact, null, ApplicationLogs::ACTION_ADD);
             DB::commit();
//.........这里部分代码省略.........
开发者ID:federosky,项目名称:ProjectPier-Core,代码行数:101,代码来源:ContactsController.class.php

示例8: add_company

 /**
  * Add company
  *
  * @param void
  * @return null
  */
 function add_company()
 {
     if (logged_user()->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $notAllowedMember = '';
     if (!Contact::canAdd(logged_user(), active_context(), $notAllowedMember)) {
         if (str_starts_with($notAllowedMember, '-- req dim --')) {
             flash_error(lang('must choose at least one member of', str_replace_first('-- req dim --', '', $notAllowedMember, $in)));
         } else {
             trim($notAllowedMember) == "" ? flash_error(lang('you must select where to keep', lang('the contact'))) : flash_error(lang('no context permissions to add', lang("contacts"), $notAllowedMember));
         }
         ajx_current("empty");
         return;
     }
     // if
     $company = new Contact();
     $company->setIsCompany(1);
     $company_data = array_var($_POST, 'company');
     if (!is_array($company_data)) {
         // set layout for modal form
         if (array_var($_REQUEST, 'modal')) {
             $this->setLayout("json");
             tpl_assign('modal', true);
         }
         $company_data = array('timezone' => logged_user()->getTimezone());
         // array
     }
     // if
     tpl_assign('company', $company);
     tpl_assign('company_data', $company_data);
     // telephone types
     $all_telephone_types = TelephoneTypes::getAllTelephoneTypesInfo();
     tpl_assign('all_telephone_types', $all_telephone_types);
     // address types
     $all_address_types = AddressTypes::getAllAddressTypesInfo();
     tpl_assign('all_address_types', $all_address_types);
     // webpage types
     $all_webpage_types = WebpageTypes::getAllWebpageTypesInfo();
     tpl_assign('all_webpage_types', $all_webpage_types);
     // email types
     $all_email_types = EmailTypes::getAllEmailTypesInfo();
     tpl_assign('all_email_types', $all_email_types);
     $company_data['all_phones'] = array();
     $company_data['all_addresses'] = array();
     $company_data['all_webpages'] = array();
     if (is_array(array_var($_POST, 'company'))) {
         foreach ($company_data as $k => &$v) {
             $v = remove_scripts($v);
         }
         $company->setFromAttributes($company_data);
         $company->setObjectName();
         try {
             $company_data['contact_type'] = 'company';
             Contacts::validate($company_data);
             DB::beginWork();
             if (isset($_SESSION['new_contact_picture']) && $_SESSION['new_contact_picture']) {
                 $company->setPictureFile($_SESSION['new_contact_picture']);
                 $_SESSION['new_contact_picture'] = null;
             }
             $company->save();
             // save phones, addresses and webpages
             $this->save_phones_addresses_webpages($company_data, $company);
             if ($company_data['email'] != "") {
                 $company->addEmail($company_data['email'], 'work', true);
             }
             // save additional emails
             $this->save_non_main_emails($company_data, $company);
             $object_controller = new ObjectController();
             $object_controller->add_subscribers($company);
             $member_ids = json_decode(array_var($_POST, 'members'));
             if (!is_null($member_ids)) {
                 $object_controller->add_to_members($company, $member_ids);
             }
             $object_controller->link_to_new_object($company);
             $object_controller->add_custom_properties($company);
             DB::commit();
             ApplicationLogs::createLog($company, ApplicationLogs::ACTION_ADD);
             flash_success(lang('success add client', $company->getObjectName()));
             evt_add("company added", array("id" => $company->getObjectId(), "name" => $company->getObjectName()));
             ajx_current("back");
             if (array_var($_REQUEST, 'modal')) {
                 evt_add("reload current panel");
             }
         } catch (Exception $e) {
             DB::rollback();
             ajx_current("empty");
             if (array_var($_REQUEST, 'modal')) {
                 ajx_extra_data(array('error' => $e->getMessage()));
             } else {
                 flash_error($e->getMessage());
             }
//.........这里部分代码省略.........
开发者ID:abhinay100,项目名称:feng_app,代码行数:101,代码来源:ContactController.class.php

示例9: add_page_action

<?php

if (!$company->isTrashed()) {
    if (User::canAdd(logged_user(), $company)) {
        add_page_action(lang('add user'), $company->getAddUserUrl(), 'ico-add');
    }
    // if
    if (Contact::canAdd(logged_user(), active_or_personal_project())) {
        add_page_action(lang('add contact'), $company->getAddContactUrl(), 'ico-add');
    }
    // if
    if ($company->canEdit(logged_user())) {
        add_page_action(lang('edit company'), $company->getEditUrl(), 'ico-edit', null, null, true);
        add_page_action(lang('edit company logo'), $company->getEditLogoUrl(), 'ico-picture', null, null, true);
        if (!$company->isOwner()) {
            add_page_action(lang('permissions'), $company->getUpdatePermissionsUrl(), 'ico-permissions', null, null, true);
        }
        // if
        if (!$company->isArchived()) {
            add_page_action(lang('archive'), "javascript:if(confirm(lang('confirm archive object'))) og.openLink('" . $company->getArchiveUrl() . "');", 'ico-archive-obj');
        } else {
            add_page_action(lang('unarchive'), "javascript:if(confirm(lang('confirm unarchive object'))) og.openLink('" . $company->getUnarchiveUrl() . "');", 'ico-unarchive-obj');
        }
    }
    // if
}
if ($company->canDelete(logged_user())) {
    if ($company->isTrashed()) {
        add_page_action(lang('restore from trash'), "javascript:if(confirm(lang('confirm restore objects'))) og.openLink('" . $company->getUntrashUrl() . "');", 'ico-restore', null, null, true);
        add_page_action(lang('delete permanently'), "javascript:if(confirm(lang('confirm delete permanently company'))) og.openLink('" . $company->getDeletePermanentlyUrl() . "');", 'ico-delete', null, null, true);
    } else {
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:31,代码来源:view_company.php

示例10: import_from_vcard

 function import_from_vcard()
 {
     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['go_back']);
     }
     if (isset($_SESSION['go_back'])) {
         unset($_SESSION['go_back']);
         ajx_current("start");
     }
     tpl_assign('import_type', 'contact');
     if (!Contact::canAdd(logged_user(), active_or_personal_project())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     $this->setTemplate('vcard_import');
     $filedata = array_var($_FILES, 'vcard_file');
     if (is_array($filedata) && !array_var($_GET, 'step2')) {
         $filename = ROOT . '/tmp/' . logged_user()->getId() . 'temp.vcf';
         copy($filedata['tmp_name'], $filename);
         //ajx_current("empty");
     } else {
         if (array_var($_GET, 'step2')) {
             $filename = ROOT . '/tmp/' . logged_user()->getId() . 'temp.vcf';
             $result = $this->read_vcard_file($filename);
             unlink($filename);
             $import_result = array('import_ok' => array(), 'import_fail' => array());
             foreach ($result as $contact_data) {
                 try {
                     DB::beginWork();
                     if (isset($contact_data['photo_tmp_filename'])) {
                         $file_id = FileRepository::addFile($contact_data['photo_tmp_filename'], array('public' => true));
                         $contact_data['picture_file'] = $file_id;
                         unlink($contact_data['photo_tmp_filename']);
                         unset($contact_data['photo_tmp_filename']);
                     }
                     if (isset($contact_data['company_name'])) {
                         $company = Companies::findOne(array("conditions" => "`name` = '" . mysql_real_escape_string($contact_data['company_name']) . "'"));
                         if ($company == null) {
                             $company = new Company();
                             $company->setName($contact_data['company_name']);
                             $company->setClientOfId(logged_user()->getCompanyId());
                             $company->save();
                             ApplicationLogs::createLog($company, null, ApplicationLogs::ACTION_ADD);
                         }
                         $contact_data['company_id'] = $company->getId();
                         unset($contact_data['company_name']);
                     }
                     $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"));
                     $contact = Contacts::findOne(array("conditions" => "firstname = '" . $fname . "' AND lastname = '" . $lname . "' OR email <> '' AND email = '" . array_var($contact_data, "email") . "'"));
                     $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) {
                         $contact->setFromAttributes($contact_data);
                         $contact->save();
                         ApplicationLogs::createLog($contact, null, $log_action);
                         $contact->setTagsFromCSV(array_var($_GET, 'tags'));
                         if (active_project() instanceof Project) {
                             $pc = ProjectContacts::findOne(array("conditions" => "contact_id = " . $contact->getId() . " AND project_id = " . active_project()->getId()));
                             if (!$pc) {
                                 $pc = new ProjectContact();
                                 $pc->setContactId($contact->getId());
                                 $pc->setProjectId(active_project()->getId());
                                 $pc->setRole(array_var($contact_data, 'role'));
                                 $pc->save();
                             }
                             $contact->addToWorkspace(active_project());
                         }
                         $import_result['import_ok'][] = array('firstname' => $fname, 'lastname' => $lname, 'email' => $contact_data['email'], 'import_status' => $contact_data['import_status']);
                     } else {
                         throw new Exception(lang('no access permissions'));
                     }
                     DB::commit();
                 } catch (Exception $e) {
                     DB::rollback();
                     $fail_msg = substr_utf($e->getMessage(), strpos_utf($e->getMessage(), "\r\n"));
                     $import_result['import_fail'][] = array('firstname' => $fname, 'lastname' => $lname, 'email' => $contact_data['email'], 'import_status' => $contact_data['import_status'], 'fail_message' => $fail_msg);
                 }
             }
             $_SESSION['go_back'] = true;
             tpl_assign('import_result', $import_result);
         }
     }
//.........这里部分代码省略.........
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:101,代码来源:ContactController.class.php


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