Пример #1
0
/**
 * Is date editable or not
 *
 * @param date $date
 * @return bool
 */
function isEditable($date)
{
    $calc = M('Date')->calcPeriod($date, getLocalDate());
    return $calc['y'] == 0 && $calc['m'] == 0 && $calc['d'] <= C('diary.min-date-shift') ? 1 : 0;
}
Пример #2
0
$INIT_CONFIG = 1;
$INIT_NO_CS_AUTH = 1;
$USE_POST_PROCESS = 0;
require_once $_SERVER["ROOT_DIR"] . "/www/diary/xml/inc/init.php";
$error = '';
$root_params = array();
// атрибуты корневого тега
if (!me()->id()) {
    $error = 'not_logged';
}
$root_params['status'] = 'ok';
$root_params = array_merge($root_params, MC('Message')->setXmlMessage(@$error, @$message, 'diary'));
// сформировать и вывести XML
$root = M('Ajax')->init('xml', $root_params);
if (!$error) {
    $root->addNode('date', array(array('now' => $now = getLocalDate(), 'min' => getMinLocalDate($now))));
    #$root->addNode('newmessages', array(array('total' => count(MC('Ticket')->getUnreadArray(me())))));
    if (MC('Diary')->showAlarm(me())) {
        $root->addNode('alert', array(array('title' => L('diary.alert_caption'), 'body' => L('diary.message'))));
    }
    #$root->addNode('receipt',array(qw2('default>'.(M('Purchase')->getNextReceipt(me())))));
    $purchaser = $root->addNode('purchaser', array(me()), array());
    $purchaser->addNode('person', me()->getFamilyPeople(), qw2('id>id() name>getFullName()'));
    $consumer = $root->addNode('consumer', array(me()), array());
    $consumer->addNode('person', me()->getExpandedFamily(), qw2('id>id() name>getFullName()'));
    $cosmetics = $root->addNode('cosmetics', array(me()), array());
    $cosmetics->addNode('owner', M('Barcode')->catalog()->getOwners(), qw2('id>id name>name prefix>prefix'));
    $catalogue = $root->addNode('catalogue', array(me()), array());
    $map = array(M('Purchase')->getCatalogue(), 'getChildren()');
    foreach ($map as $item) {
        $catalogue = $catalogue->addNode('node', $item, qw2('id>id() name>name() example>example() default>use_as_default weight>isWeight() factory>isFactory() action>useCatalogue()'));