本文整理汇总了PHP中Contacts::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Contacts::delete方法的具体用法?PHP Contacts::delete怎么用?PHP Contacts::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contacts
的用法示例。
在下文中一共展示了Contacts::delete方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onDelete
private function onDelete()
{
if ($this->_accessLevel < ACCESS_LEVEL_DELETE) {
CommonErrors::fatal(COMMONERROR_PERMISSION, $this, 'Invalid user level for action.');
}
/* Bail out if we don't have a valid contact ID. */
if (!$this->isRequiredIDValid('contactID', $_GET)) {
CommonErrors::fatal(COMMONERROR_BADINDEX, $this, 'Invalid contact ID.');
}
$contactID = $_GET['contactID'];
if (!eval(Hooks::get('CONTACTS_DELETE_PRE'))) {
return;
}
$contacts = new Contacts($this->_siteID);
$contacts->delete($contactID);
/* Delete the MRU entry if present. */
$_SESSION['CATS']->getMRU()->removeEntry(DATA_ITEM_CONTACT, $contactID);
if (!eval(Hooks::get('CONTACTS_DELETE_POST'))) {
return;
}
CATSUtility::transferRelativeURI('m=contacts&a=listByView');
}
示例2: complete_installation
/**
* Finish the installation - create owner company and administrator
*
* @param void
* @return null
*/
function complete_installation()
{
if (Contacts::getOwnerCompany() instanceof Contact) {
die('Owner company already exists');
// Somebody is trying to access this method even if the user already exists
}
// if
$form_data = array_var($_POST, 'form');
tpl_assign('form_data', $form_data);
if (array_var($form_data, 'submited') == 'submited') {
try {
$admin_password = trim(array_var($form_data, 'admin_password'));
$admin_password_a = trim(array_var($form_data, 'admin_password_a'));
if (trim($admin_password) == '') {
throw new Error(lang('password value required'));
}
// if
if ($admin_password != $admin_password_a) {
throw new Error(lang('passwords dont match'));
}
// if
DB::beginWork();
Contacts::delete();
// clear users table
// Create a company
$company = new Contact();
$company->setFirstName(array_var($form_data, 'company_name'));
$company->setObjectName();
$company->setIsCompany(true);
$company->save();
// Init default colors
set_config_option('brand_colors_head_back', "424242");
set_config_option('brand_colors_tabs_back', "e7e7e7");
set_config_option('brand_colors_head_font', "FFFFFF");
set_config_option('brand_colors_tabs_font', "333333");
// Create the administrator user
$administrator = new Contact();
$pergroup = PermissionGroups::findOne(array('conditions' => "`name`='Super Administrator'"));
$administrator->setUserType($pergroup->getId());
$administrator->setCompanyId($company->getId());
$administrator->setUsername(array_var($form_data, 'admin_username'));
$administrator->setPassword($admin_password);
$administrator->setFirstname(array_var($form_data, 'admin_username'));
$administrator->setObjectName();
$administrator->save();
$user_password = new ContactPassword();
$user_password->setContactId($administrator->getId());
$user_password->password_temp = $admin_password;
$user_password->setPasswordDate(DateTimeValueLib::now());
$user_password->setPassword(cp_encrypt($admin_password, $user_password->getPasswordDate()->getTimestamp()));
$user_password->save();
//Add email after save because is needed.
$administrator->addEmail(array_var($form_data, 'admin_email'), 'personal', true);
//permissions
$permission_group = new PermissionGroup();
$permission_group->setName('Account Owner');
$permission_group->setContactId($administrator->getId());
$permission_group->setIsContext(false);
$permission_group->setType("permission_groups");
$permission_group->save();
$administrator->setPermissionGroupId($permission_group->getId());
$administrator->save();
$company->setCreatedById($administrator->getId());
$company->setUpdatedById($administrator->getId());
$company->save();
$contact_pg = new ContactPermissionGroup();
$contact_pg->setContactId($administrator->getId());
$contact_pg->setPermissionGroupId($permission_group->getId());
$contact_pg->save();
// tab panel permissions
$panels = TabPanels::getEnabled();
foreach ($panels as $panel) {
$tpp = new TabPanelPermission();
$tpp->setPermissionGroupId($administrator->getPermissionGroupId());
$tpp->setTabPanelId($panel->getId());
$tpp->save();
}
// dimension permissions
$dimensions = Dimensions::findAll();
foreach ($dimensions as $dimension) {
if ($dimension->getDefinesPermissions()) {
$cdp = ContactDimensionPermissions::findOne(array("conditions" => "`permission_group_id` = " . $administrator->getPermissionGroupId() . " AND `dimension_id` = " . $dimension->getId()));
if (!$cdp instanceof ContactDimensionPermission) {
$cdp = new ContactDimensionPermission();
$cdp->setPermissionGroupId($administrator->getPermissionGroupId());
$cdp->setContactDimensionId($dimension->getId());
}
$cdp->setPermissionType('allow all');
$cdp->save();
// contact member permisssion entries
$members = $dimension->getAllMembers();
foreach ($members as $member) {
$ots = DimensionObjectTypeContents::getContentObjectTypeIds($dimension->getId(), $member->getObjectTypeId());
$ots[] = $member->getObjectId();
//.........这里部分代码省略.........
示例3: deleteAction
/** Delete a contact
*/
public function deleteAction()
{
$this->_flashMessenger->addMessage($this->_noChange);
if ($this->_request->isPost()) {
$id = (int) $this->_request->getPost('id');
$del = $this->_request->getPost('del');
if ($del == 'Yes' && $id > 0) {
$contacts = new Contacts();
$where = 'id = ' . $id;
$contacts->delete($where);
}
$this->_flashMessenger->addMessage('Contact information deleted! This cannot be undone.');
$this->_redirect($this->_redirectUrl);
} else {
$id = (int) $this->_request->getParam('id');
if ($id > 0) {
$contacts = new Contacts();
$this->view->contact = $contacts->fetchRow('id =' . $id);
}
}
}
示例4: delete
/**
* Removes a company and all associated records from the system.
*
* @param integer Company ID
* @return void
*/
public function delete($companyID)
{
/* Delete the company. */
$sql = sprintf("DELETE FROM\n company\n WHERE\n company_id = %s\n AND\n site_id = %s", $companyID, $this->_siteID);
$this->_db->query($sql);
$history = new History($this->_siteID);
$history->storeHistoryDeleted(DATA_ITEM_COMPANY, $companyID);
/* Find associated contacts. */
$sql = sprintf("SELECT\n contact_id AS contactID\n FROM\n contact\n WHERE\n company_id = %s\n AND\n site_id = %s", $companyID, $this->_siteID);
$contactsRS = $this->_db->getAllAssoc($sql);
/* Find associated job orders. */
$sql = sprintf("SELECT\n joborder_id AS jobOrderID\n FROM\n joborder\n WHERE\n company_id = %s\n AND\n site_id = %s", $companyID, $this->_siteID);
$jobOrdersRS = $this->_db->getAllAssoc($sql);
/* Find associated attachments. */
$attachments = new Attachments($this->_siteID);
$attachmentsRS = $attachments->getAll(DATA_ITEM_COMPANY, $companyID);
/* Delete associated contacts. */
$contacts = new Contacts($this->_siteID);
foreach ($contactsRS as $rowIndex => $row) {
$contacts->delete($row['contactID']);
}
/* Delete associated job orders. */
$jobOrders = new JobOrders($this->_siteID);
foreach ($jobOrdersRS as $rowIndex => $row) {
$jobOrders->delete($row['jobOrderID']);
}
/* Delete associated attachments. */
foreach ($attachmentsRS as $rowNumber => $row) {
$attachments->delete($row['attachmentID']);
}
/* Delete from saved lists. */
$sql = sprintf("DELETE FROM\n saved_list_entry\n WHERE\n data_item_id = %s\n AND\n site_id = %s\n AND\n data_item_type = %s", $this->_db->makeQueryInteger($companyID), $this->_siteID, DATA_ITEM_COMPANY);
$this->_db->query($sql);
/* Delete extra fields. */
$this->extraFields->deleteValueByDataItemID($companyID);
}
示例5: complete_installation
/**
* Finish the installation - create owner company and administrator
*
* @param void
* @return null
*/
function complete_installation() {
if(Contacts::getOwnerCompany() instanceof Contact) {
die('Owner company already exists'); // Somebody is trying to access this method even if the user already exists
} // if
$form_data = array_var($_POST, 'form');
tpl_assign('form_data', $form_data);
if(array_var($form_data, 'submited') == 'submited') {
try {
$admin_password = trim(array_var($form_data, 'admin_password'));
$admin_password_a = trim(array_var($form_data, 'admin_password_a'));
if(trim($admin_password) == '') {
throw new Error(lang('password value required'));
} // if
if($admin_password <> $admin_password_a) {
throw new Error(lang('passwords dont match'));
} // if
DB::beginWork();
Contacts::delete(); // clear users table
// Create a company
$company = new Contact();
$company->setFirstName(array_var($form_data, 'company_name'));
$company->setObjectName();
$company->setIsCompany(true);
$company->save();
// Init default colors
set_config_option('brand_colors_head_back', "000000");
set_config_option('brand_colors_tabs_back', "14780e");
set_config_option('brand_colors_head_font', "ffffff");
set_config_option('brand_colors_tabs_font', "ffffff");
// Create the administrator user
$administrator = new Contact();
$pergroup = PermissionGroups::findOne(array('conditions'=>"`name`='Super Administrator'"));
$administrator->setUserType($pergroup->getId());
$administrator->setCompanyId($company->getId());
$administrator->setUsername(array_var($form_data, 'admin_username'));
$administrator->setPassword($admin_password);
$administrator->setFirstname(array_var($form_data, 'admin_username'));
$administrator->setObjectName();
$administrator->save();
$user_password = new ContactPassword();
$user_password->setContactId($administrator->getId());
$user_password->password_temp = $admin_password;
$user_password->setPasswordDate(DateTimeValueLib::now());
$user_password->setPassword(cp_encrypt($admin_password, $user_password->getPasswordDate()->getTimestamp()));
$user_password->save();
//Add email after save because is needed.
$administrator->addEmail(array_var($form_data, 'admin_email'), 'personal', true);
//permissions
$permission_group = new PermissionGroup();
$permission_group->setName('Account Owner');
$permission_group->setContactId($administrator->getId());
$permission_group->setIsContext(false);
$permission_group->setType("permission_groups");
$permission_group->save();
$administrator->setPermissionGroupId($permission_group->getId());
$administrator->save();
$company->setCreatedById($administrator->getId());
$company->setUpdatedById($administrator->getId());
$company->save();
$contact_pg = new ContactPermissionGroup();
$contact_pg->setContactId($administrator->getId());
$contact_pg->setPermissionGroupId($permission_group->getId());
$contact_pg->save();
// tab panel permissions
$panels = TabPanels::getEnabled();
foreach ($panels as $panel) {
$tpp = new TabPanelPermission();
$tpp->setPermissionGroupId($administrator->getPermissionGroupId());
$tpp->setTabPanelId($panel->getId());
$tpp->save();
}
// dimension permissions
$dimensions = Dimensions::findAll();
foreach ($dimensions as $dimension) {
//.........这里部分代码省略.........