Example #1
0
 function doRegisterConfirmAction()
 {
     @($email = DevblocksPlatform::importGPC($_REQUEST['email'], 'string', ''));
     @($code = trim(DevblocksPlatform::importGPC($_REQUEST['code'], 'string', '')));
     @($pass = DevblocksPlatform::importGPC($_REQUEST['pass'], 'string', ''));
     if (!$this->allow_logins) {
         die;
     }
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl->assign('register_email', $email);
     $tpl->assign('register_code', $code);
     if (!empty($email) && !empty($pass) && !empty($code)) {
         if (null != ($addy = DAO_Address::lookupAddress($email, false)) && null != ($auth = DAO_AddressAuth::get($addy->id)) && !empty($auth) && !empty($auth->confirm) && 0 == strcasecmp($code, $auth->confirm)) {
             $fields = array(DAO_AddressAuth::PASS => md5($pass));
             DAO_AddressAuth::update($addy->id, $fields);
         } else {
             $tpl->assign('register_error', sprintf("The confirmation code you entered does not match our records.  Try again."));
             DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('portal', $this->getPortal(), 'register', 'confirm')));
             return;
         }
     } else {
         $tpl->assign('register_error', sprintf("You must enter a valid e-mail address, confirmation code and desired password to continue."));
         DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('portal', $this->getPortal(), 'register', 'confirm')));
         return;
     }
 }
Example #2
0
 function doImportAction()
 {
     $active_worker = CerberusApplication::getActiveWorker();
     if (!$active_worker->hasPriv('core.addybook.import')) {
         return;
     }
     @($pos = DevblocksPlatform::importGPC($_REQUEST['pos'], 'array', array()));
     @($field = DevblocksPlatform::importGPC($_REQUEST['field'], 'array', array()));
     @($sync_column = DevblocksPlatform::importGPC($_REQUEST['sync_column'], 'string', ''));
     @($include_first = DevblocksPlatform::importGPC($_REQUEST['include_first'], 'integer', 0));
     @($is_blank_unset = DevblocksPlatform::importGPC($_REQUEST['is_blank_unset'], 'integer', 0));
     @($replace_passwords = DevblocksPlatform::importGPC($_REQUEST['replace_passwords'], 'integer', 0));
     $visit = CerberusApplication::getVisit();
     $db = DevblocksPlatform::getDatabaseService();
     $csv_file = $visit->get('import.last.csv', '');
     $type = $visit->get('import.last.type', '');
     $fp = fopen($csv_file, "rt");
     if (!$fp) {
         return;
     }
     // [JAS]: Do we need to consume a first row of headings?
     if (!$include_first) {
         @fgetcsv($fp, 8192, ',', '"');
     }
     while (!feof($fp)) {
         $parts = fgetcsv($fp, 8192, ',', '"');
         if (empty($parts) || 1 == count($parts) && is_null($parts[0])) {
             continue;
         }
         $fields = array();
         $custom_fields = array();
         $sync_field = '';
         $sync_val = '';
         // Overrides
         $contact_password = '';
         foreach ($pos as $idx => $p) {
             $key = $field[$idx];
             $val = $parts[$idx];
             if (!empty($key)) {
                 // Organizations
                 if ($type == "orgs") {
                     switch ($key) {
                         // Multi-Line
                         case 'street':
                             @($val = isset($fields[$key]) ? $fields[$key] . ', ' . $val : $val);
                             break;
                             // Dates
                         // Dates
                         case 'created':
                             @($val = !is_numeric($val) ? strtotime($val) : $val);
                             break;
                     }
                     // Custom fields
                     if ('cf_' == substr($key, 0, 3)) {
                         $custom_fields[substr($key, 3)] = $val;
                     } else {
                         $fields[$key] = $val;
                     }
                     // Addresses
                 } elseif ($type == "addys") {
                     switch ($key) {
                         // Org (from string into id)
                         case 'contact_org_id':
                             if (null != ($org_id = DAO_ContactOrg::lookup($val, true))) {
                                 $val = $org_id;
                             } else {
                                 $val = 0;
                             }
                             break;
                         case 'password':
                             $key = null;
                             $contact_password = $val;
                             break;
                     }
                     // Custom fields
                     if ('cf_' == substr($key, 0, 3)) {
                         $custom_fields[substr($key, 3)] = $val;
                     } else {
                         $fields[$key] = $val;
                     }
                 }
                 if (!empty($key)) {
                     // [JAS]: Are we looking for matches in a certain field?
                     if ($sync_column == $key && !empty($val)) {
                         $sync_field = $key;
                         $sync_val = $val;
                     }
                 }
             }
         }
         if (!empty($fields)) {
             if ($type == "orgs") {
                 @($orgs = DAO_ContactOrg::getWhere(!empty($sync_field) && !empty($sync_val) ? sprintf('%s = %s', $sync_field, $db->qstr($sync_val)) : sprintf('name = %s', $db->qstr($fields['name']))));
                 if (isset($fields['name'])) {
                     if (empty($orgs)) {
                         $id = DAO_ContactOrg::create($fields);
                     } else {
                         $id = key($orgs);
                         DAO_ContactOrg::update($id, $fields);
                     }
                 }
             } elseif ($type == "addys") {
                 if (!empty($sync_field) && !empty($sync_val)) {
                     @($addys = DAO_Address::getWhere(sprintf('%s = %s', $sync_field, $db->qstr($sync_val))));
                 }
                 if (isset($fields['email'])) {
                     if (empty($addys)) {
                         $id = DAO_Address::create($fields);
                     } else {
                         $id = key($addys);
                         DAO_Address::update($id, $fields);
                     }
                     // Overrides
                     if (!empty($contact_password) && !empty($id)) {
                         if ($replace_passwords) {
                             // always replace
                             DAO_AddressAuth::update($id, array(DAO_AddressAuth::PASS => $contact_password));
                         } else {
                             // only replace if null
                             if (null == ($auth = DAO_AddressAuth::get($id))) {
                                 DAO_AddressAuth::update($id, array(DAO_AddressAuth::PASS => $contact_password));
                             }
                         }
                     }
                 }
             }
         }
         if (!empty($custom_fields) && !empty($id)) {
             // Format (typecast) and set the custom field types
             $source_ext_id = $type == "orgs" ? ChCustomFieldSource_Org::ID : ChCustomFieldSource_Address::ID;
             DAO_CustomFieldValue::formatAndSetFieldValues($source_ext_id, $id, $custom_fields, $is_blank_unset);
         }
     }
     @unlink($csv_file);
     // nuke the imported file
     $visit->set('import.last.csv', null);
     $visit->set('import.last.type', null);
     DevblocksPlatform::redirect(new DevblocksHttpResponse(array('contacts', 'import')));
 }
Example #3
0
 private function _postValidateAction($path)
 {
     $xml_in = simplexml_load_string($this->getPayload());
     @($email = $xml_in->params->email);
     @($pass_hash = $xml_in->params->pass_hash);
     @($confirmation_code = $xml_in->params->confirmation_code);
     if (null != ($addy = DAO_Address::lookupAddress($email, false))) {
         $auth = DAO_AddressAuth::get($addy->id);
         if (!empty($auth->pass) && $pass_hash == $auth->pass) {
             $xml = new SimpleXMLElement("<success></success>");
             $xml->addChild('address', $email);
         }
         if (!empty($auth->confirm) && $confirmation_code == $auth->confirm) {
             $xml = new SimpleXMLElement("<success></success>");
             $xml->addChild('address', $email);
         }
     } else {
         $xml = new SimpleXMLElement("<failure></failure>");
         $xml->addChild('validation_failed');
     }
     $this->_render($xml->asXML());
 }
Example #4
0
 function doLogin()
 {
     $umsession = UmPortalHelper::getSession();
     //		if(!$this->allow_logins)
     //			die();
     @($email = DevblocksPlatform::importGPC($_REQUEST['email']));
     @($pass = DevblocksPlatform::importGPC($_REQUEST['pass']));
     $valid = false;
     // [TODO] Test login combination using the appropriate adapter
     if (null != ($addy = DAO_Address::lookupAddress($email, false))) {
         $auth = DAO_AddressAuth::get($addy->id);
         if (!empty($auth->pass) && md5($pass) == $auth->pass) {
             $valid = true;
             $umsession->setProperty('sc_login', $addy);
         }
     }
     if (!$valid) {
         $umsession->setProperty('sc_login', null);
     }
     DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('portal', UmPortalHelper::getCode())));
 }