Esempio n. 1
0
    $newRes->set('pagetitle', $fullcode);
    $newRes->set('template', $template);
    $newRes->set('published', 1);
    $newRes->set('hidemenu', 1);
    $newRes->set('parent', $pa_resid);
    $newRes->set('content_type', 7);
    // set JSON as content type
    $newRes->save();
    if (!$newRes->isMember('Blogger_resources_group')) {
        $newRes->joinGroup('Blogger_resources_group');
    }
    if (!$newRes->isMember('Menegers_resource_group')) {
        $newRes->joinGroup('Menegers_resource_group');
    }
}
$pa_resid = $scriptProperties['pa_resid'];
// id ресурса промо-акции
$tpl_id = 8;
// шаблон Bootstrap.inner.pcodes
// Получаем уникальный код акции, хранимый в TV
$pa_code = $modx->runSnippet('pdoField', array('id' => $pa_resid, 'field' => 'pa-code'));
$new_start_pcode = getStartNumber($pa_resid, $pa_code);
$count = 500;
while ($count > 0) {
    $new_start_pcode_str = str_pad($new_start_pcode, 6, '0', STR_PAD_LEFT);
    addResource($new_start_pcode_str, $pa_resid, $tpl_id);
    $count--;
    echo "<br> Код сгенерирован: " . $new_start_pcode_str;
    $new_start_pcode++;
}
//return 'Промо коды сгенерированы: ' . $count;
Esempio n. 2
0
 function testAddResourced()
 {
     $r = addResource(new folksoQuery(array(), array('folksonewtitle' => 'New new!', 'folksores' => 'http://newone.com'), array()), new folksoDBconnect('localhost', 'tester_dude', 'testy', 'testostonomie'), $this->fks);
     $this->assertIsA($r, folksoResponse, 'addResource() not returning folksoResponse object');
     $this->assertEqual($r->status, 201, 'addResource() not returning 201');
     $this->assertNotEqual($r->status, 500, 'addResource() returning 500 - DB error');
     $is = isHead(new folksoQuery(array(), array('folksores' => 'http://newone.com'), array()), new folksoDBconnect('localhost', 'tester_dude', 'testy', 'testostonomie'), $this->fks2);
     $this->assertEqual($is->status, 200, "isHead() not reporting creation of new resource by addResource()");
 }