Skip to content

Commit

Permalink
Merge branch '6.8.4' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
jstanden committed Nov 14, 2014
2 parents 4e75528 + c7c2fb3 commit 7003468
Show file tree
Hide file tree
Showing 24 changed files with 172 additions and 34 deletions.
4 changes: 2 additions & 2 deletions api/Application.class.php
Expand Up @@ -46,8 +46,8 @@
\* - Jeff Standen, Darren Sugita, Dan Hildebrandt
* Webgroup Media LLC - Developers of Cerb
*/
define("APP_BUILD", 2014102401);
define("APP_VERSION", '6.8.3');
define("APP_BUILD", 2014111301);
define("APP_VERSION", '6.8.4');

define("APP_MAIL_PATH", APP_STORAGE_PATH . '/mail/');

Expand Down
13 changes: 13 additions & 0 deletions api/app/Mail.php
Expand Up @@ -300,6 +300,19 @@ static function compose($properties) {

$headers->addTextHeader('X-Mailer','Cerb ' . APP_VERSION . ' (Build '.APP_BUILD.')');

// Custom headers

if(isset($properties['headers']) && is_array($properties['headers']))
foreach($properties['headers'] as $header_key => $header_val) {
if(!empty($header_key) && is_string($header_key) && is_string($header_val)) {
if(NULL == ($header = $headers->get($header_key))) {
$headers->addTextHeader($header_key, $header_val);
} else {
$header->setValue($header_val);
}
}
}

// Body

switch($content_format) {
Expand Down
7 changes: 5 additions & 2 deletions features/cerberusweb.core/api/cron.classes.php
Expand Up @@ -906,6 +906,7 @@ private function _handleImportWorker($xml) {
$sFirstName = (string) $xml->first_name;
$sLastName = (string) $xml->last_name;
$sEmail = (string) $xml->email;
$sPassword = (string) $xml->password;
$isSuperuser = (integer) $xml->is_superuser;

// Dupe check worker email
Expand All @@ -914,8 +915,6 @@ private function _handleImportWorker($xml) {
return true;
}

// Don't import passwords, just require workers to authenticate again

$fields = array(
DAO_Worker::EMAIL => $sEmail,
DAO_Worker::FIRST_NAME => $sFirstName,
Expand All @@ -925,6 +924,10 @@ private function _handleImportWorker($xml) {
);
$worker_id = DAO_Worker::create($fields);

// Set pasword auth, if exists
if(!empty($sPassword))
DAO_Worker::setAuth($worker_id, $sPassword, true);

// Address to Worker
DAO_AddressToWorker::assign($sEmail, $worker_id, true);

Expand Down
6 changes: 5 additions & 1 deletion features/cerberusweb.core/api/dao/address.php
Expand Up @@ -306,11 +306,15 @@ static function lookupAddress($email,$create_if_null=false) {

if(is_array($addresses) && !empty($addresses)) {
$address = array_shift($addresses);

} elseif($create_if_null) {
$fields = array(
self::EMAIL => $email
);
$id = DAO_Address::create($fields);

if(false == ($id = DAO_Address::create($fields)))
return false;

$address = DAO_Address::get($id);
}

Expand Down
5 changes: 5 additions & 0 deletions features/cerberusweb.core/api/dao/custom_field.php
Expand Up @@ -966,6 +966,11 @@ static function getTypes() {

return $fields;
}

static function hasMultipleValues($type) {
$multiple_types = array(Model_CustomField::TYPE_MULTI_CHECKBOX, Model_CustomField::TYPE_FILES);
return in_array($type, $multiple_types);
}
};

class Context_CustomField extends Extension_DevblocksContext {
Expand Down
6 changes: 4 additions & 2 deletions features/cerberusweb.core/api/dao/worker.php
Expand Up @@ -437,7 +437,7 @@ static function hasAuth($worker_id) {
return (is_array($worker_auth) && isset($worker_auth['pass_hash']));
}

static function setAuth($worker_id, $password) {
static function setAuth($worker_id, $password, $asMd5=false) {
$db = DevblocksPlatform::getDatabaseService();

if(is_null($password)) {
Expand All @@ -448,10 +448,12 @@ static function setAuth($worker_id, $password) {
} else {
$salt = CerberusApplication::generatePassword(12);

$password_hash = ($asMd5) ? $password : md5($password);

return $db->Execute(sprintf("REPLACE INTO worker_auth_hash (worker_id, pass_hash, pass_salt, method) ".
"VALUES (%d, %s, %s, %d)",
$worker_id,
$db->qstr(sha1($salt.md5($password))),
$db->qstr(sha1($salt.$password_hash)),
$db->qstr($salt),
0
));
Expand Down
4 changes: 3 additions & 1 deletion features/cerberusweb.core/api/uri/config/groups.php
Expand Up @@ -122,7 +122,9 @@ function saveGroupAction() {
$fields = array(
DAO_Group::NAME => $name,
);
$id = DAO_Group::create($fields);

if(false == ($id = DAO_Group::create($fields)))
return false;
}

// Members
Expand Down
9 changes: 7 additions & 2 deletions features/cerberusweb.core/api/uri/config/workers.php
Expand Up @@ -102,6 +102,10 @@ function saveWorkerPeekAction() {
DAO_Worker::delete($id);

} else {
// Validate the email address
if(false == ($worker_address = DAO_Address::lookupAddress($email, true)))
return false;

if(empty($id) && null == DAO_Worker::getByEmail($email)) {
if(empty($password_new)) {
// Creating new worker. If password is empty, email it to them
Expand Down Expand Up @@ -162,7 +166,8 @@ function saveWorkerPeekAction() {
DAO_Worker::AT_MENTION_NAME => $at_mention_name,
);

$id = DAO_Worker::create($fields);
if(false == ($id = DAO_Worker::create($fields)))
return false;

// View marquee
if(!empty($id) && !empty($view_id)) {
Expand Down Expand Up @@ -203,7 +208,7 @@ function saveWorkerPeekAction() {

// Set the name on the worker email address

if(false != ($worker_address = DAO_Address::lookupAddress($email, true))) {
if($worker_address instanceof Model_Address) {
$addy_fields = array();

if(empty($worker_address->first_name) && !empty($first_name))
Expand Down
10 changes: 7 additions & 3 deletions features/cerberusweb.core/api/uri/contacts.php
Expand Up @@ -1023,7 +1023,9 @@ function saveAddressAction() {

if($id==0) {
$fields = $fields + array(DAO_Address::EMAIL => $email);
$id = DAO_Address::create($fields);

if(false == ($id = DAO_Address::create($fields)))
return false;

@$add_watcher_ids = DevblocksPlatform::sanitizeArray(DevblocksPlatform::importGPC($_REQUEST['add_watcher_ids'],'array',array()),'integer',array('unique','nonzero'));
if(!empty($add_watcher_ids))
Expand Down Expand Up @@ -1117,7 +1119,8 @@ function saveOrgPeekAction() {
);

if($id==0) {
$id = DAO_ContactOrg::create($fields);
if(false == ($id = DAO_ContactOrg::create($fields)))
return false;

// Watchers
@$add_watcher_ids = DevblocksPlatform::sanitizeArray(DevblocksPlatform::importGPC($_REQUEST['add_watcher_ids'],'array',array()),'integer',array('unique','nonzero'));
Expand Down Expand Up @@ -1617,7 +1620,8 @@ function saveContactPeekAction() {
$fields[DAO_ContactPerson::EMAIL_ID] = $address->id;
$fields[DAO_ContactPerson::CREATED] = time();

$id = DAO_ContactPerson::create($fields);
if(false == ($id = DAO_ContactPerson::create($fields)))
return false;

// Link address to contact person
DAO_Address::update($address->id, array(
Expand Down
12 changes: 9 additions & 3 deletions features/cerberusweb.core/api/uri/internal.php
Expand Up @@ -1483,7 +1483,8 @@ function saveSnippetsPeekAction() {

if(empty($id)) {
if($active_worker->hasPriv('core.snippets.actions.create')) {
$id = DAO_Snippet::create($fields);
if(false == ($id = DAO_Snippet::create($fields)))
return false;

// Custom field saves
@$field_ids = DevblocksPlatform::importGPC($_POST['field_ids'], 'array', array());
Expand Down Expand Up @@ -1554,7 +1555,7 @@ function snippetPasteAction() {
'id' => $id,
'context_id' => $context_id,
'has_custom_placeholders' => !empty($snippet->custom_placeholders),
'text' => rtrim($output,"\r\n") . "\n",
'text' => rtrim(str_replace("\r","",$output),"\r\n") . "\n",
));
}

Expand Down Expand Up @@ -2221,7 +2222,9 @@ private function _viewIncrementalExport($cursor_key) {
DAO_Attachment::STORAGE_SHA1HASH => $sha1_hash,
DAO_Attachment::UPDATED => time(),
);
$id = DAO_Attachment::create($fields);

if(false == ($id = DAO_Attachment::create($fields)))
return false;

$fp = fopen($cursor['temp_file'], 'r');
Storage_Attachments::put($id, $fp);
Expand Down Expand Up @@ -3917,6 +3920,9 @@ function saveDecisionPopupAction() {
DAO_DecisionNode::PARAMS_JSON => '',
));

if(false == $id)
return false;

} elseif(isset($_REQUEST['trigger_id'])) { // Trigger
@$trigger_id = DevblocksPlatform::importGPC($_REQUEST['trigger_id'],'integer', 0);
@$title = DevblocksPlatform::importGPC($_REQUEST['title'],'string', '');
Expand Down
4 changes: 3 additions & 1 deletion features/cerberusweb.core/api/uri/internal/calendars.php
Expand Up @@ -230,7 +230,9 @@ function saveCalendarPeekAction() {
DAO_Calendar::OWNER_CONTEXT_ID => $owner_ctx_id,
DAO_Calendar::PARAMS_JSON => json_encode($params),
);
$id = DAO_Calendar::create($fields);

if(false == ($id = DAO_Calendar::create($fields)))
return false;

// Watchers
@$add_watcher_ids = DevblocksPlatform::sanitizeArray(DevblocksPlatform::importGPC($_REQUEST['add_watcher_ids'],'array',array()),'integer',array('unique','nonzero'));
Expand Down
Expand Up @@ -176,7 +176,9 @@ function savePeekPopupJsonAction() {
DAO_CalendarRecurringProfile::IS_AVAILABLE => $is_available ? 1 : 0,
DAO_CalendarRecurringProfile::PATTERNS => $patterns,
);
$id = DAO_CalendarRecurringProfile::create($fields);

if(false == ($id = DAO_CalendarRecurringProfile::create($fields)))
return false;

// Context Link (if given)
@$link_context = DevblocksPlatform::importGPC($_REQUEST['link_context'],'string','');
Expand Down
3 changes: 2 additions & 1 deletion features/cerberusweb.core/api/uri/profiles/file_bundle.php
Expand Up @@ -156,7 +156,8 @@ function savePeekAction() {
$fields[DAO_FileBundle::OWNER_CONTEXT_ID] = $owner_context_id;

if(empty($id)) { // New
$id = DAO_FileBundle::create($fields);
if(false == ($id = DAO_FileBundle::create($fields)))
return false;

// Watchers
@$add_watcher_ids = DevblocksPlatform::sanitizeArray(DevblocksPlatform::importGPC($_REQUEST['add_watcher_ids'],'array',array()),'integer',array('unique','nonzero'));
Expand Down
Expand Up @@ -147,7 +147,8 @@ function savePeekAction() {
);

if(empty($id)) { // New
$id = DAO_MailHtmlTemplate::create($fields);
if(false == ($id = DAO_MailHtmlTemplate::create($fields)))
return false;

// Context Link (if given)
@$link_context = DevblocksPlatform::importGPC($_REQUEST['link_context'],'string','');
Expand Down
Expand Up @@ -180,7 +180,9 @@ function savePeekAction() {
DAO_VirtualAttendant::OWNER_CONTEXT_ID => $owner_ctx_id,
DAO_VirtualAttendant::PARAMS_JSON => json_encode($params),
);
$id = DAO_VirtualAttendant::create($fields);

if(false == ($id = DAO_VirtualAttendant::create($fields)))
return false;

// Context Link (if given)
@$link_context = DevblocksPlatform::importGPC($_REQUEST['link_context'],'string','');
Expand Down
4 changes: 3 additions & 1 deletion features/cerberusweb.core/api/uri/tasks.php
Expand Up @@ -78,7 +78,9 @@ function saveTaskPeekAction() {

} else {
$custom_fields = DAO_CustomFieldValue::parseFormPost(CerberusContexts::CONTEXT_TASK, $field_ids);
$id = DAO_Task::create($fields, $custom_fields);

if(false == ($id = DAO_Task::create($fields, $custom_fields)))
return false;

@$add_watcher_ids = DevblocksPlatform::sanitizeArray(DevblocksPlatform::importGPC($_REQUEST['add_watcher_ids'],'array',array()),'integer',array('unique','nonzero'));
if(!empty($add_watcher_ids))
Expand Down
2 changes: 1 addition & 1 deletion features/cerberusweb.core/resources/js/cerberus.js
Expand Up @@ -56,7 +56,7 @@ var markitupParsedownDefaults = {
onShiftEnter: {keepDefault:false, openWith:'\n\n'},
markupSet: [
{name:'Bold', key:'B', openWith:'**', closeWith:'**', className:'b'},
{name:'Italic', key:'I', openWith:'_', closeWith:'_', className:'i'},
{name:'Italic', openWith:'_', closeWith:'_', className:'i'},
{name:'Bulleted List', openWith:'- ', className:'ul' },
{name:'Numeric List', className:'ol', openWith:function(markItUp) {
return markItUp.line+'. ';
Expand Down
6 changes: 6 additions & 0 deletions features/cerberusweb.core/strings.xml
Expand Up @@ -534,6 +534,12 @@
<tu tuid='common.quick_search'>
<tuv xml:lang="en_US"><seg>Quick Search</seg></tuv>
</tu>
<tu tuid='common.recipient'>
<tuv xml:lang="en_US"><seg>recipient</seg></tuv>
</tu>
<tu tuid='common.recipients'>
<tuv xml:lang="en_US"><seg>recipients</seg></tuv>
</tu>
<tu tuid='common.refresh'>
<tuv xml:lang="en_US"><seg>refresh</seg></tuv>
</tu>
Expand Down
Expand Up @@ -25,7 +25,7 @@
</tr>
<tr>
<td width="0%" nowrap="nowrap" align="right" valign="top"><b>{'common.email'|devblocks_translate}</b>: </td>
<td width="100%"><input type="text" name="email" value="{$worker->email}" class="required" style="width:98%;"></td>
<td width="100%"><input type="text" name="email" value="{$worker->email}" class="required email" style="width:98%;"></td>
</tr>
<tr>
<td width="0%" nowrap="nowrap" align="right" valign="top">{'worker.at_mention_name'|devblocks_translate}: </td>
Expand Down
2 changes: 1 addition & 1 deletion features/cerberusweb.core/templates/context_links/tab.tpl
Expand Up @@ -48,7 +48,7 @@ function linkAddContext(ref) {
}
}
var $popup = genericAjaxPopup('peek','c=internal&a=showPeekPopup&context=' + $context + '&context_id=0&link_context={$context}&link_context_id={$context_id}',null,false,'500');
var $popup = genericAjaxPopup('peek','c=internal&a=showPeekPopup&context=' + $context + '&context_id=0&link_context={$context}&link_context_id={$context_id}',null,false,'750');
$popup.one('dialogclose', reload_action);
$select.val('');
Expand Down
Expand Up @@ -9,6 +9,9 @@
{if !empty($link_context)}
<input type="hidden" name="link_context" value="{$link_context}">
<input type="hidden" name="link_context_id" value="{$link_context_id}">
{elseif !empty($draft->params.link_context)}
<input type="hidden" name="link_context" value="{$draft->params.link_context}">
<input type="hidden" name="link_context_id" value="{$draft->params.link_context_id}">
{/if}
<input type="hidden" name="format" value="{if ($draft && $draft->params.format == 'parsedown') || $mail_reply_html}parsedown{/if}">

Expand Down
35 changes: 35 additions & 0 deletions libs/devblocks/Devblocks.class.php
Expand Up @@ -427,6 +427,40 @@ static function strBase32Decode($str) {

static function stripHTML($str, $strip_whitespace=true, $skip_blockquotes=false) {

// Pre-process some HTML entities that confuse UTF-8

$str = str_ireplace(
array(
'&rsquo;', // '
'&#8217;',
'&#x2019;',
'&hellip;', // ...
'&#8230;',
'&#x2026;',
'&ldquo;', // "
'&#8220;',
'&#x201c;',
'&rdquo;', // "
'&#8221;',
'&#x201d;',
),
array(
"'",
"'",
"'",
'...',
'...',
'...',
'"',
'"',
'"',
'"',
'"',
'"',
),
$str
);

// Pre-process blockquotes
if(!$skip_blockquotes) {
$dom = new DOMDocument('1.0', LANG_CHARSET_CODE);
Expand Down Expand Up @@ -1831,6 +1865,7 @@ static function sanitizeArray($array, $type, $options=array()) {
return $array;
break;

case 'int':
case 'integer':
$array = _DevblocksSanitizationManager::arrayAs($array, 'integer');

Expand Down

0 comments on commit 7003468

Please sign in to comment.