public static function process_password_reset() { // grab our email template and send it to this email address. $email = trim(strtolower($_REQUEST['email'])); $success = false; if (strlen($email) > 4 && strpos($email, '@')) { $users = module_user::get_users(array('email' => $email)); $contacts = module_user::get_contacts(array('email' => $email)); $users = array_merge($users, $contacts); foreach ($users as $user) { // send auto login link for this user. if (strtolower($user['email']) == $email) { $template = module_template::get_template_by_key('password_reset'); $template->assign_values($user); if ($user['customer_id']) { $url = module_user::link_open_contact($user['user_id'], false, $user, true); } else { $url = module_user::link_open($user['user_id'], false, $user, true); } $url .= (strpos($url, '?') ? '&' : '?') . 'reset_password='******'user_id']); $url .= '&auto_login='******'user_id']); $template->assign_values(array('auto_login_url' => $url)); $html = $template->render('html'); $email = module_email::new_email(); $email->replace_values = $user; $email->set_to('user', $user['user_id']); $email->set_subject($template->description); // do we send images inline? $email->set_html($html); if ($email->send()) { // it worked successfully!! $success = true; } else { /// log err? echo 'failed to send email, sorry'; exit; } } } } if ($success || !module_config::c('password_reset_debug', 0)) { set_message('Please check your email for password reset instructions.'); } else { echo 'No users found matching ' . htmlspecialchars($email); exit; } redirect_browser(_BASE_HREF); }
public static function handle_import_row($row, $debug, $add_to_group, $extra_options) { $debug_string = ''; if (!isset($row['name'])) { $row['name'] = ''; } if (!isset($row['url'])) { $row['url'] = ''; } if (isset($row['website_id']) && (int) $row['website_id'] > 0) { // check if this ID exists. $website = self::get_website($row['website_id']); if (!$website || $website['website_id'] != $row['website_id']) { $row['website_id'] = 0; } } if (!isset($row['website_id']) || !$row['website_id']) { $row['website_id'] = 0; } if (isset($row['name']) && strlen(trim($row['name']))) { // we have a website name! // search for a website based on name. $website = get_single('website', 'name', $row['name']); if ($website && $website['website_id'] > 0) { $row['website_id'] = $website['website_id']; } } else { if (isset($row['url'])) { $row['name'] = $row['url']; } } if (!$row['website_id'] && isset($row['url']) && strlen(trim($row['url']))) { // we have a url! find a match too. $website = get_single('website', 'url', $row['url']); if ($website && $website['website_id'] > 0) { $row['website_id'] = $website['website_id']; } } if (!strlen($row['name']) && !strlen($row['url'])) { $debug_string .= _l('No website data to import'); if ($debug) { echo $debug_string; } return false; } // duplicates. //print_r($extra_options);exit; if (isset($extra_options['duplicates']) && $extra_options['duplicates'] == 'ignore' && (int) $row['website_id'] > 0) { if ($debug) { $debug_string .= _l('Skipping import, duplicate of website %s', self::link_open($row['website_id'], true)); echo $debug_string; } // don't import duplicates return false; } $row['customer_id'] = 0; // todo - support importing of this id? nah if (isset($row['customer_name']) && strlen(trim($row['customer_name'])) > 0) { // check if this customer exists. $customer = get_single('customer', 'customer_name', $row['customer_name']); if ($customer && $customer['customer_id'] > 0) { $row['customer_id'] = $customer['customer_id']; $debug_string .= _l('Linked to customer %s', module_customer::link_open($row['customer_id'], true)) . ' '; } else { $debug_string .= _l('Create new customer: %s', htmlspecialchars($row['customer_name'])) . ' '; } } else { $debug_string .= _l('No customer') . ' '; } if ($row['website_id']) { $debug_string .= _l('Replace existing website: %s', self::link_open($row['website_id'], true)) . ' '; } else { $debug_string .= _l('Insert new website: %s', htmlspecialchars($row['url'])) . ' '; } $customer_primary_user_id = 0; if ($row['customer_id'] > 0 && isset($row['customer_contact_email']) && strlen(trim($row['customer_contact_email']))) { $users = module_user::get_users(array('customer_id' => $row['customer_id'] > 0)); foreach ($users as $user) { if (strtolower(trim($user['email'])) == strtolower(trim($row['customer_contact_email']))) { $customer_primary_user_id = $user['user_id']; $debug_string .= _l('Customer primary contact is: %s', module_user::link_open_contact($customer_primary_user_id, true)) . ' '; break; } } } if ($debug) { echo $debug_string; return true; } if (isset($extra_options['duplicates']) && $extra_options['duplicates'] == 'ignore' && $row['customer_id'] > 0) { // don't update customer record with new one. } else { if (isset($row['customer_name']) && strlen(trim($row['customer_name'])) > 0 || $row['customer_id'] > 0) { // update customer record with new one. $row['customer_id'] = update_insert('customer_id', $row['customer_id'], 'customer', $row); if (isset($row['customer_contact_fname']) || isset($row['customer_contact_email'])) { $data = array('customer_id' => $row['customer_id']); if (isset($row['customer_contact_fname'])) { $data['name'] = $row['customer_contact_fname']; } if (isset($row['customer_contact_lname'])) { $data['last_name'] = $row['customer_contact_lname']; } if (isset($row['customer_contact_email'])) { $data['email'] = $row['customer_contact_email']; } if (isset($row['customer_contact_phone'])) { $data['phone'] = $row['customer_contact_phone']; } $customer_primary_user_id = update_insert("user_id", $customer_primary_user_id, "user", $data); module_customer::set_primary_user_id($row['customer_id'], $customer_primary_user_id); } } } $website_id = (int) $row['website_id']; // check if this ID exists. $website = self::get_website($website_id); if (!$website || $website['website_id'] != $website_id) { $website_id = 0; } $website_id = update_insert("website_id", $website_id, "website", $row); // ad notes if possible if (isset($row['notes']) && strlen(trim($row['notes']))) { if (class_exists('module_note', false) && module_note::is_plugin_enabled()) { module_note::save_note(array('owner_table' => 'website', 'owner_id' => $website_id, 'note' => trim($row['notes']), 'note_time' => time())); } } // handle any extra fields. $extra = array(); foreach ($row as $key => $val) { if (!strlen(trim($val))) { continue; } if (strpos($key, 'extra:') !== false) { $extra_key = str_replace('extra:', '', $key); if (strlen($extra_key)) { $extra[$extra_key] = $val; } } } if ($extra) { foreach ($extra as $extra_key => $extra_val) { // does this one exist? $existing_extra = module_extra::get_extras(array('owner_table' => 'website', 'owner_id' => $website_id, 'extra_key' => $extra_key)); $extra_id = false; foreach ($existing_extra as $key => $val) { if ($val['extra_key'] == $extra_key) { $extra_id = $val['extra_id']; } } $extra_db = array('extra_key' => $extra_key, 'extra' => $extra_val, 'owner_table' => 'website', 'owner_id' => $website_id); $extra_id = (int) $extra_id; update_insert('extra_id', $extra_id, 'extra', $extra_db); } } foreach ($add_to_group as $group_id => $tf) { module_group::add_to_group($group_id, $website_id, 'website'); } return $website_id; }
<?php /** * Copyright: dtbaker 2012 * Licence: Please check CodeCanyon.net for licence details. * More licence clarification available here: http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca * Package Date: 2015-11-25 02:55:20 * IP Address: 67.79.165.254 */ $search = isset($_REQUEST['search']) && is_array($_REQUEST['search']) ? $_REQUEST['search'] : array(); $search['customer_id'] = 0; $users = module_user::get_users($search); // grab a list of customer sites $sites = array(); $user_statuses = module_user::get_statuses(); $roles = module_security::get_roles(); $heading = array('title' => _l('User Administration'), 'button' => array(), 'main' => true); if (module_user::can_i('create', 'Users', 'Config')) { $heading['button'][] = array('title' => 'Add new user', 'type' => 'add', 'url' => $module->link_open('new')); } print_heading($heading); ?> <form action="" method="post"> <?php $search_bar = array('elements' => array('name' => array('title' => _l('Users Name:'), 'field' => array('type' => 'text', 'name' => 'search[generic]', 'value' => isset($search['generic']) ? $search['generic'] : ''))));
<form action="" method="post"> <input type="hidden" name="_process" value="save_security_role" /> <input type="hidden" name="security_role_id" value="<?php echo $security_role_id; ?> " /> <?php /** ROLE DETAILS */ $fieldset_data = array('heading' => array('type' => 'h3', 'title' => 'Role Details'), 'class' => 'tableclass tableclass_form tableclass_full', 'elements' => array()); $fieldset_data['elements']['name'] = array('title' => 'Name', 'fields' => array(array('type' => 'text', 'name' => 'name', 'value' => $security_role['name']))); if ((int) $security_role_id > 0) { $fieldset_data['elements']['users'] = array('title' => 'Name', 'fields' => array(function () use($security_role_id) { $users = module_user::get_users(array('security_role_id' => $security_role_id)); $contacts = module_user::get_contacts(array('security_role_id' => $security_role_id)); $url1 = module_user::link_open_contact(false); $url1 .= strpos($url1, '?') ? '&' : '?'; $url2 = module_user::link_open(false); $url2 .= strpos($url1, '?') ? '&' : '?'; _e('There are <a href="%s">%s customer contacts</a> and <a href="%s">%s system users</a> with this role.', $url1 . 'search[security_role_id]=' . (int) $security_role_id, count($contacts), $url2 . 'search[security_role_id]=' . (int) $security_role_id, count($users)); })); } $fieldset_data['elements']['defaults'] = array('title' => 'Load Defaults', 'fields' => array(array('type' => 'select', 'name' => 'load_defaults', 'value' => '', 'options' => array('{"Change Request|change_request|Change Requests|Permissions":["view"],"Customer|customer|Customers|Permissions":["view"],"Customer|user|Contacts|Permissions":["view","edit","create"],"Customer|customer|All Customer Contacts|Permissions":["view","edit"],"Invoice|invoice|Invoices|Permissions":["view"],"Job|job|Jobs|Permissions":["view"],"Job|job|Job Tasks|Permissions":["view"],"Ticket|ticket|Tickets|Permissions":["view","create"],"Website|website|Websites|Permissions":["view"],"Customer Data Access|config|Only customer I am assigned to as a contact|drop_down":["view"],"Job Data Access|config|Jobs from customers I have access to|drop_down":["view"],"Job Task Creation|config|Created tasks require admin approval|drop_down":["view"],"Ticket Access|config|Only tickets from my customer account|drop_down":["view"],"User Account Access|config|Only Contact Accounts|drop_down":["view"],"User Specific|config|Can User Login|checkbox":["view"]}' => _l('Customer View Only'), '{"Company|company|Company|Permissions":["view"],"Customer|customer|Customers|Permissions":["view","edit","create"],"Customer|user|Contacts|Permissions":["view","edit","create"],"Customer|customer|All Customer Notes|Permissions":["view","edit","create"],"Customer|customer|All Customer Contacts|Permissions":["view"],"Customer|customer|Customer Groups|Permissions":["view","edit","create"],"File|file|Files|Permissions":["view","edit","create"],"File|file|File Comments|Permissions":["view","create"],"Invoice|invoice|Invoices|Permissions":["view","edit","create"],"Invoice|invoice|Invoice Notes|Permissions":["view","edit","create"],"Invoice|invoice|Invoice Payments|Permissions":["edit","create"],"Job|job|Jobs|Permissions":["view","edit","create"],"Job|job|Job Notes|Permissions":["view","edit","create"],"Job|job|Job Tasks|Permissions":["view","edit","create"],"Job|job|Job Groups|Permissions":["view","edit","create"],"Job|job|Job Advanced|Permissions":["view"],"Job Discussion|job_discussion|Job Discussions|Permissions":["view"],"Pin|pin|Header Pin|Permissions":["view","edit","create","delete"],"Ticket|ticket|Tickets|Permissions":["view","edit","create"],"User|user|User Notes|Permissions":["view","edit","create"],"Website|website|Websites|Permissions":["view","edit","create"],"Website|website|Website Notes|Permissions":["view","edit","create"],"Website|website|Website Groups|Permissions":["view","edit","create"],"Company Data Access|config|Only companies I am assigned to in staff area|drop_down":["view"],"Customer Data Access|config|Only customers from companies I have access to|drop_down":["view"],"Invoice Data Access|config|Invoices from Jobs I have access to|drop_down":["view"],"Job Data Access|config|Only jobs I am assigned to|drop_down":["view"],"Job Task Creation|config|Created tasks do not require approval|drop_down":["view"],"Job Task Data Access|config|All tasks within a job|drop_down":["view"],"Ticket Access|config|Only tickets from my customer account|drop_down":["view"],"User Account Access|config|Only My Account|drop_down":["view"],"User Specific|config|Can User Login|checkbox":["view"],"User Specific|config|Show Quick Search|checkbox":["view"],"User Specific|config|Show Dashboard Alerts|checkbox":["view"],"User Specific|config|Show Dashboard Todo List|checkbox":["view"],"User Specific|config|Receive File Upload Alerts|checkbox":["view"]}' => _l('Staff Member'), '{"Company|company|Company|Permissions":["view"],"Customer|customer|Customers|Permissions":["view","edit","create"],"Customer|user|Contacts|Permissions":["view","edit","create"],"Customer|customer|All Customer Notes|Permissions":["view","edit","create"],"Customer|customer|All Customer Contacts|Permissions":["view","edit"],"Customer|customer|Customer Groups|Permissions":["view","edit","create"],"Customer|customer|All Lead Contacts|Permissions":["view","edit"],"Customer|customer|Lead Groups|Permissions":["view","edit","create"],"Customer|customer|All Lead Notes|Permissions":["view","edit","create"],"File|file|Files|Permissions":["view","edit","create"],"File|file|File Comments|Permissions":["view","create"],"Invoice|invoice|Invoices|Permissions":["view","edit","create"],"Invoice|invoice|Invoice Notes|Permissions":["view","edit","create"],"Invoice|invoice|Invoice Payments|Permissions":["edit","create"],"Job|job|Jobs|Permissions":["view","edit","create"],"Job|job|Job Notes|Permissions":["view","edit","create"],"Job|job|Job Tasks|Permissions":["view","edit","create"],"Job|job|Job Groups|Permissions":["view","edit","create"],"Job|job|Job Advanced|Permissions":["view"],"Job Discussion|job_discussion|Job Discussions|Permissions":["view"],"Pin|pin|Header Pin|Permissions":["view","edit","create","delete"],"Ticket|ticket|Tickets|Permissions":["view","edit","create"],"User|user|User Notes|Permissions":["view","edit","create"],"Vendor|user|Contacts|Permissions":["view","edit"],"Vendor|vendor|Vendors|Permissions":["view"],"Vendor|vendor|All Vendor Contacts|Permissions":["view"],"Website|website|Websites|Permissions":["view","edit","create"],"Website|website|Website Notes|Permissions":["view","edit","create"],"Website|website|Website Groups|Permissions":["view","edit","create"],"Calendar Data Access|config|Only from Customers or assigned items|drop_down":["view"],"Company Data Access|config|All companies in system|drop_down":["view"],"Customer Data Access|config|Only customers I am assigned to as a staff member|drop_down":["view"],"File Data Access|config|Only files from customers I have access to|drop_down":["view"],"Invoice Data Access|config|Invoices from customers I have access to|drop_down":["view"],"Job Data Access|config|Jobs from customers I have access to|drop_down":["view"],"Job Task Creation|config|Created tasks do not require approval|drop_down":["view"],"Job Task Data Access|config|All tasks within a job|drop_down":["view"],"Quote Data Access|config|Quotes from customers I have access to|drop_down":["view"],"Quote Task Creation|config|Created tasks do not require approval|drop_down":["view"],"Quote Task Data Access|config|All tasks within a quote|drop_down":["view"],"Ticket Access|config|Only tickets from my customer account|drop_down":["view"],"User Account Access|config|All Contact and User Accounts|drop_down":["view"],"Vendor Data Access|config|Only vendor I am assigned to as a contact|drop_down":["view"],"User Specific|config|Can User Login|checkbox":["view"],"User Specific|config|Show Quick Search|checkbox":["view"],"User Specific|config|Show Dashboard Alerts|checkbox":["view"],"User Specific|config|Show Dashboard Todo List|checkbox":["view"],"User Specific|config|Receive File Upload Alerts|checkbox":["view"],"User Specific|config|Receive File Comment Alerts|checkbox":["view"]}' => _l('Staff Member Improved'), '{"Calendar|calendar|Calendar|Permissions":["view","edit","create"],"Company|company|Company|Permissions":["view"],"Config|user|Users|Permissions":["view","edit"],"Config|user|Users Passwords|Permissions":["view","edit","create"],"Config|user|Staff Settings|Permissions":["edit"],"Customer|user|Contacts|Permissions":["view","edit","create","delete"],"Customer|customer|Customers|Permissions":["view","edit","create","delete"],"Customer|customer|Leads|Permissions":["view","edit","create"],"Customer|customer|All Customer Notes|Permissions":["view","edit","create","delete"],"Customer|customer|All Customer Contacts|Permissions":["view","edit"],"Customer|customer|Customer Groups|Permissions":["view","edit","create","delete"],"Customer|customer|Export Customers|Permissions":["view"],"Customer|customer|Import Customers|Permissions":["view"],"Customer|customer|Customer Staff|Permissions":["edit"],"Customer|customer|Customer Credit|Permissions":["edit"],"Customer|customer|Export Leads|Permissions":["view"],"Customer|customer|Import Leads|Permissions":["view"],"Customer|customer|All Lead Contacts|Permissions":["view","edit"],"Customer|customer|Lead Groups|Permissions":["view","delete"],"Customer|customer|All Lead Notes|Permissions":["delete"],"File|file|Files|Permissions":["view","edit","create","delete"],"File|file|File Comments|Permissions":["view","create","delete"],"File|file|File Approval|Permissions":["edit"],"Finance|finance|Dashboard Finance Summary|Permissions":["view"],"Invoice|invoice|Invoices|Permissions":["view","edit","create","delete"],"Invoice|invoice|Invoice Notes|Permissions":["view","edit","create","delete"],"Invoice|invoice|Invoice Payments|Permissions":["edit","create"],"Invoice|invoice|Export Invoices|Permissions":["view"],"Job|job|Jobs|Permissions":["view","edit","create","delete"],"Job|job|Job Notes|Permissions":["view","edit","create","delete"],"Job|job|Job Tasks|Permissions":["view","edit","create"],"Job|job|Job Groups|Permissions":["view","edit","create","delete"],"Job|job|Job Advanced|Permissions":["view"],"Job|job|Export Job Tasks|Permissions":["view"],"Job|job|Import Job Tasks|Permissions":["view"],"Job|job|Export Jobs|Permissions":["view"],"Job|job|Import Jobs|Permissions":["view"],"Job Discussion|job_discussion|Job Discussions|Permissions":["view"],"User|user|User Notes|Permissions":["view","edit","create"],"Website|website|Websites|Permissions":["view","edit","create","delete"],"Website|website|Website Notes|Permissions":["view","edit","create","delete"],"Website|website|Website Groups|Permissions":["view","edit","create","delete"],"Website|website|Export Websites|Permissions":["view"],"Website|website|Import Websites|Permissions":["view"],"Calendar Data Access|config|Only from Customers or assigned items|drop_down":["view"],"Company Data Access|config|Only companies I am assigned to in staff area|drop_down":["view"],"Customer Data Access|config|Only customers from companies I have access to|drop_down":["view"],"File Data Access|config|Only files from customers I have access to|drop_down":["view"],"Invoice Data Access|config|Invoices from customers I have access to|drop_down":["view"],"Job Data Access|config|Jobs from customers I have access to|drop_down":["view"],"Job Task Creation|config|Created tasks do not require approval|drop_down":["view"],"Job Task Data Access|config|All tasks within a job|drop_down":["view"],"Quote Data Access|config|Quotes from customers I have access to|drop_down":["view"],"Quote Task Creation|config|Created tasks do not require approval|drop_down":["view"],"Quote Task Data Access|config|All tasks within a quote|drop_down":["view"],"Ticket Access|config|Only tickets from my customer account|drop_down":["view"],"User Account Access|config|Only Contact Accounts|drop_down":["view"],"Vendor Data Access|config|Only vendors from companies I have access to|drop_down":["view"],"User Specific|config|Show Quick Search|checkbox":["view"],"User Specific|config|Show Dashboard Alerts|checkbox":["view"],"User Specific|config|Show Dashboard Todo List|checkbox":["view"],"User Specific|config|Receive File Upload Alerts|checkbox":["view"],"User Specific|config|Can User Login|checkbox":["view"],"User Specific|config|Receive File Comment Alerts|checkbox":["view"]}' => _l('Reseller')), 'help' => 'This will override any options selected below and replace them with defaults. You can change the selected permissions once the defaults are loaded'))); echo module_form::generate_fieldset($fieldset_data); unset($fieldset_data); /** PERMIOSSIONS */ ob_start(); hook_handle_callback('layout_column_half', 1); ?>